Learing how to code the arduino uno. Working this practice problem that is supposed to be a 3way switch to light an LED using interrrupts. i keep getting an error and i dont know why. Help please?
The reason it won't compile is blink() needs to be defined before setup() and you are missing a closing brace in loop(). However, even if you get it to compile it will not work.
I can't tell from the code how it is supposed to work and your description doesn't make sense to me. Can you better describe how the switches are supposed to make the LED light? Should it light when either switch is pressed? Should it only stay lit while the switch is pressed?
The following condition will never be true:
if (((PBInterrupt == LOW || PB2Interrupt == LOW) && LED == LOW))
PBInterrupt, PB2Interrupt, and LED are pin numbers and they are constants so they will never equal LOW. I assume you meant the following:
6v6gt:
Don’t underestimate the Arduino IDE C++ “extension” for creating hidden function prototypes.
You are correct. Just adding the closing brace for loop() makes it compile because without that the IDE can't properly create the blink prototype. I keep forgetting about the IDE "extension".
It is easy to forget but you really start paying attention to it when it puts the prototype in the wrong place, say before the declaration of the data type of arguments used in that prototype, giving rise to mysterious and inappropriate error messages.