Hello!
I am trying to modify the default main.py SBC0 code to use a WHILE loop in order for:
- The rocker switch controls the blinking LED: switch on = LED blinks; switch off = LED does not blink
- Starts off not blinking
- When I turn on the switch, the LED should be on for 2 secs and off for 2 secs (blink "cycle")
- Make a variable counting the number of times the LED blink
- Print the number of blinks once the switch is turned off.
Finally, I want to use FOR loop to blink the LED 9 times even when the switch is off.
Thank you in advance! Here is what I have:
from gpio import *
from time import *
def main():
pinMode(2, IN)
pinMode(1, OUT)
while True:
if digitalRead(2) == HIGH:
digitalWrite(1, HIGH)
print("Blinking")
else:
digitalWrite(1, LOW);
delay(2000)
#delay(500)
if __name__ == "__main__":
main()