Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import sys
- import os
- import RPi.GPIO as GPIO
- red_light = 13 ##GPIO 13 connect to IN3
- yellow_light = 16 ##GPIO 16 connect to IN2
- green_light = 7 ##GPIO 7 connect to IN1
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(green_light, GPIO.OUT)
- GPIO.setup(red_light, GPIO.OUT)
- GPIO.setup(yellow_light, GPIO.OUT)
- GPIO.output(red_light,True)
- GPIO.output(yellow_light,True)
- GPIO.output(green_light,True)
- def LightsReady(numTimes, speed):
- for i in range(0,numTimes):## Run loop numTimes
- print "Iteration " + str(i+1)## Print current loop
- GPIO.output(green_light,False)## Switch on pin 7
- GPIO.output(yellow_light,False)## Switch on pin 15
- GPIO.output(red_light,False)## Switch on pin 13
- time.sleep(speed)## Wait
- GPIO.output(green_light,True)## Switch off pin 7
- GPIO.output(yellow_light,True)## Switch off pin 15
- GPIO.output(red_light,True)## Switch off pin 13
- print "Done" ## When loop is complete, print "Done"
- ##GPIO.cleanup()
- LightsReady(3,.2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement