Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify the python code to make the LED blink three times rapidly followed by a p

ID: 3802419 • Letter: M

Question

Modify the python code to make the LED blink three times rapidly followed by a pause of five

seconds, followed by four rapid blinks, another pause and repeating the whole thing again in a loop till

you terminate the python script.

#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
def Blink():
    for i in range(0,3):
        print "blink #" + str(i+1)      
   GPIO.output(17,True)
        time.sleep(1)
        GPIO.output(17,False)
        time.sleep(1)
    print "done!!"
    GPIO.cleanup()
Blink()

Explanation / Answer

Python script will be look like

for i in range(0,3):
print "blink #" + str(i+1)
GPIO.output(17,True)
time.sleep(1)
GPIO.output(17,False)
time.sleep(1)
    for i in range(0,4):
    print "blink #" + str(i+1)
   GPIO.output(17,True)
    time.sleep(1)
    GPIO.output(17,False)
    time.sleep(1)
print "done!!"
GPIO.cleanup()
Blink()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote