Speed Control with Potentiometer and LCD — Arduino Uno simulation

Adjusts a speed value using a slide potentiometer and displays it on an I2C LCD.

An interactive Arduino Uno circuit simulation you can run free in your browser on Velxio, by yangrigorovich6.

Components

Sketch code

// Blink LED Example
// Toggles the built-in LED on pin 13
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd1(0x27,16,2);

void setup() {
  lcd1.init();
  lcd1.backlight();
  pinMode(9,INPUT_PULLUP);
}

void loop() {
  speedInfo();
  delay(100);
}

void speedInfo(){
  int speed = map(analogRead(A0),0,1023,0,200);
  if(!digitalRead(9)){
    lcd1.clear();
    lcd1.print("Test");
  }else{
    lcd1.clear();
  lcd1.setCursor(0,0);
  lcd1.print("Speed: ");
  lcd1.print(speed);
  lcd1.print(" Km/H");
  }
}