Hello,
Newbie question. I am using the following code to display the values from a potentiometer on an LCD display and meter (the meter part works fine). It is working well, the LCD displays the values from the potentiometer properly. My question is, is it possible to use those values and have the LCD display show alternate figures for the values? So instead of 0-1021, could it display the values on a scale of 1 to 5? The values arriving from the pot remain the same but they are "translated" on the display to a number from 1 to 5?
I'm sorry if this is a silly question, I am fairly new to Arduino programming. Also, any basic corrections to the code would be appreciated.
#include <LiquidCrystal.h> // include the library code
#define MeterPin 5
#define PotentiometerPin A1
LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // initialize the library with the numbers of the interface pins
void setup()
{
pinMode(MeterPin, OUTPUT);
lcd.begin(16, 2); // set up the LCD's number of columns and rows
Serial.begin(9600);
}
void loop()
{
int potentiometerValue = analogRead(PotentiometerPin);
int power = map(potentiometerValue, 0, 1021, 0, 255);
analogWrite(MeterPin, power);
lcd.setCursor(6, 0); // set the cursor to column 6, line 0
lcd.print(potentiometerValue); // print out the value on LCD Display
analogWrite(MeterPin, power);
delay(1000);
lcd.clear();
}