I've posted the full code on the first page. I've just updated it to where I am now.
using my LCD menu and buttons I am trying to change the value of "restingVoltage" which is a float in the global scope. Once the value has changed via my menu and buttons the code in my "home" menu will run with the newly set values.
One last thing that would be useful to know, or if you can point me in the right direction to find out...
When I hold the up or down button in a menu, I want the value of X to change like this :
13.6, 13.7, 13.8, 13.9 ,14.0, 14.1 and so on....
But at the money when I hold a button it changes like this:
13.6, 14.6, 15.6, 16.6....
I've played about with it for most of the day and don't seem to be getting very far, or at least, I know how it doesn't work!
void menuItem2() { // Function executes when you select the 2nd item from main menu
float x;
x = 13.6;
int activeButton = 0;
int button;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("VOlTS NOW =");
lcd.setCursor(0,1);
lcd.print ("REST SET");
menuState2=true;
// this will run while menuState2 is true
while(menuState2==true){
int sensorValue1 = analogRead(A2);
voltage1 = sensorValue1 * (50.00 / 1024);
// Setup and Print Values to LCD
lcd.setCursor (10,0);
lcd.print(voltage1);
lcd.setCursor (10,1);
lcd.print(restingVoltage);
readKey = analogRead(0);
if(readKey == 99){ //holding the UP button
(restingVoltage =x++); // will count from 13.6
restingVoltage = x; // the value stopped at will be the value of X and restingVoltage
}
else if (readKey == 256) { // holding the DOWN button
(restingVoltage =x--); // will count from X down
restingVoltage = x; // the value stopped at will be the value of X and restingVoltage
}
delay(100);
readKey = analogRead(0);
if (readKey < 790) {
delay(100);
readKey = analogRead(0);
button = evaluateButton(readKey);
switch (button) {
case 4: // This case will execute if the "back" button is pressed
button = 0;
activeButton = 1;
menuState2=false;
break;
}
}
}
} [code]
I have no idea. I don't normally but thanks for pointing it out.
Again, I'm not sure - Thanks for pointing out that it was unnecessary.
I didn't think that, I just used that code as a way I could test the value was actually being changing so when I upped my input voltage the voltage was compared to the new changed values.
I asked for help to be able to add 0.1 because my other attempts didn't work.