Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
EduKit 1 problems
#1
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:

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.
Reply


Messages In This Thread
EduKit 1 problems - by birdwatcher - Dec-22-2019, 04:26 PM
RE: EduKit 1 problems - by Larz60+ - Dec-22-2019, 05:14 PM
RE: EduKit 1 problems - by birdwatcher - Dec-22-2019, 05:31 PM
RE: EduKit 1 problems - by Larz60+ - Dec-22-2019, 10:31 PM
RE: EduKit 1 problems - by birdwatcher - Dec-23-2019, 09:17 PM
RE: EduKit 1 problems - by Larz60+ - Dec-24-2019, 02:01 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020