Hello, I've been struggling for about 1 1/2 hours to get this right but it's not working!! I've declared 'boolean DeadBatt = true' in the void setup(), and the goal here is to blink some LED lights on and off ten times when a battery is low, but I only want this piece of code to run once in the void loop() if it is true, so I've added this Boolean variable...
Void loop()
if digitalRead(LowBattery, LOW) && boolean DeadBatt = true; repeated jibberish to blink LEDs...
final boolean DeadBatt = false ;
The main error I keep getting is 'expected '(' before 'digitalRead', so I've tried adding some brackets and then I get another error... Anyway I've tried a bunch of things but it just won't co-operate! Any ideas?
Thanks, I'll try plugging that in tomorrow! Your corrected block of code looks exactly like one I had also tried (all the time I had spent trying to get it right included researching page after page of different examples and definitions and syntax, etc...
I had also done the whole removing the boolean thing because I realized that, just like declaring an integer at the start as well, I had already given the boolean a name (DeadBatt) and so it should work to try to recall just 'DeadBatt'.
Anyway, I'll try that again in the morning. Maybe had a small thing out of place when I had tried that.
I've declared 'boolean DeadBatt = true' in the void setup(),
This like the one in your if statement is a local variable.
A global variable must be declared outside of any function usually at the top before void setup().