Dec-22-2019, 04:26 PM
(This post was last modified: Dec-22-2019, 04:59 PM by ichabod801.)
Hi, I'm relatively new to Python but have some experience coding on the EduKit 1. I have been set a challenge of writing code so that when I press the button "x" amount of times the LEDs flash that many times as well. The code I have written sets a countdown that you can press the button however many times you want in but the LEDs always flash during that countdown and not after it like I want them to. Apparently there are no syntax errors or anything of the sort. I have done some research and looked in some coding manuals and EduKit worksheets but can't find anything helpful. I am using Python 3(IDLE) by the way and run my code with Thonny. Here is my code:
Birdwatcher.
from gpiozero import Button from gpiozero import LED import time counter = 0 red = LED(18) yellow = LED(23) green = LED(24) red.off() green.off() yellow.off() button = Button(25) print ("Starting") time.sleep(1) for n in range (500): n + 1 print(n) print ("I'm off") for number in range (2): red.on() green.on() yellow.on() time.sleep(0.2) red.off() green.off() yellow.off() time.sleep(0.2)Thanks,
Birdwatcher.