Hey, first post and this might be a stupid question, but I am new to programming. Using a microcontroller (mbed LPC1768) to run the program.
I wrote a code that will use 5 led lights to count to 25 in binary. What i wish to achieve is that the counter will reset and start counting from 0 when i flick a switch on the board (p13). This code works with a click button that is normally off (0). But when i use a switch that i can turn on or off. The counter just stay at 0 when the button is on (1). Can anyone help me with this problem? Should be easy to fix.
So i am pretty sure its even on or off. Therefor 0 or 1.
The code works when i flick the switch back and forth. Reset when the button is sending a current and start counting from zero again when i flick the switch off again.
So the problem is in the code. When the switch is on (1), the bottom half "else" will loop and always start with "counter = 0". So it will never start counting upwards again. Need to make the "counter = 0" only work once. For both "button" options.