Hi, I'm a student with little experience using Arduino. I have a UNOFreaduino board, and a 5 button keypad for this segment of the code.
code is as follows:
int x = analogRead(A0);
int tubeNum = 1;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void keypad() {
if (0<=x && x<=15) {
tubeNum = tubeNum + 1;
}
else if (40<=x && x<=55) {
tubeNum = tubeNum - 1;
}
else if (540<=x && x<=555) {
tubeNum=1;
}
Serial.println(tubeNum);
Serial.print(" ");
Serial.print(x);
}
void loop() {
// put your main code here, to run repeatedly:
keypad();
delay(1000);
}
//end
I would like to know why my code does not allow the values of the 5 button keypad to be incorporated in. I'm on a tight schedule and this has a very high percentage so I would be very thankful if anyone could give suggestions on how to improve it.
Thanks!