Hi i am using an Arduino Uno and I am trying to make what is essentially a really simple menu what I have so far allows me to use a button to shift through cases. but I want a button that when pressed in a certain case preforms a task. I've added an if statement inside one of the cases and it uploads but doesn't seem to do anything. I am very new to this so my fundamental thinking is probably wrong, what I have is below any help would be appreciated thanks.
Hi sorry for the slow reply I've moved the button1.loop(); but button 1 still seems to have no effect. Also I have pin 9 connected to an LED so i can see what's going on and it lights as soon as i get to case 1 rather than when I press button 1. I'm using an Arduino Uno R3.
welcome to the Arduino-Forum.
Well done posting code as a code-section in your very first posting
Your code has too less and not informative enough serial printing / lcd printing for beeing able to analyse what your code is doing
In the debug / testphase your code should talk clear and unique
you used multiple times "Test1"
I changed this that in each case the case X is printed on your lcd
additionally you should use the serial monitor for analysing
because the serial monitor has much more lines and longer lines to offer
than your lcd
Here is the modificated code-version. I only changed textes and deleted too much empty lines
The logic is absolutely the same
Thanks I've changed it to this but LED now wont activate at all regardless of button press , I've stuck the button into a different sketch to see if it works and seems to work fine.
button1.loop();
if (button1.isPressed())
{
Serial.println("TEST ACTIVE");
digitalWrite(9, HIGH);
}
break;
Hi yes sorry I just sent the LCD into a meltdown managed to get it back to normal now but it seems printing countIn3 prints endless zeroes in the monitor which is probably why the LCD went mad I'm not sure why its doing that tho any ideas thanks for all your help btw.
If printing count shows the number of times that the button has been pressed, as it should, but countIn3 is always zero then there is something wrong with your calculation of countIn3
hmm maybe I've mixed up the buttons somewhere i might have a go at reorganising some of the wiring and see if that changes anything. I've had to leave it at work today so ill check back in when i can connect again, thanks for all your help