Raspberry Pi Workshop Kit Tutorials – 3 LED Blink
Welcome to the Raspberry Pi Workshop Tutorials, brought to you by ModMyPi, BuyaPi.ca, and PiShop.us. In this series, we’ll demonstrate nine projects that can be made using the YouTube Workshop Kit for Raspberry Pi. These projects are a great way to familiarize yourself with the Pi’s input and output functions, as well as creating programs in Python that we’ll use to control the Pi’s hardware. Tutorial 3 - LED Blink Circuit Diagram: http://www.modmypi.com/download/led_bb.png Tutorial 3 Download: http://www.modmypi.com/download/youtube_workshop_3_blink.pdf View Tutorial Online: https://www.modmypi.com/blog/youtube-workshop-kit/gpio-and-python-39-blinking-led *** Code Used In This Tutorial *** #!/usr/bin/python from time import sleep # import the time function from the sleep library import RPi.GPIO as GPIO # import our GPIO library GPIO.setmode(GPIO.BCM) # set the board numbering system to BCM # setup our output pins GPIO.setup(17,GPIO.OUT) GPIO.setup(27,GPIO.OUT) # Turn LEDs on print "lights on" GPIO.output(17,GPIO.HIGH) GPIO.output(27,GPIO.HIGH) sleep(1) # sleep for 1 second # Turn LEDs off print "lights off" GPIO.output(17,GPIO.LOW) GPIO.output(27,GPIO.LOW) sleep(1) # Turn LEDs on print "lights on" GPIO.output(17,GPIO.HIGH) GPIO.output(27,GPIO.HIGH) sleep(1) # Turn LEDs off print "lights off" GPIO.output(17,GPIO.LOW) GPIO.output(27,GPIO.LOW) GPIO.cleanup() # the clean-up function will reset all the configurations made in this script. This will stop the warnings we got from the tutorial 2. ***************************** #!/usr/bin/python # import libraries from time import sleep import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) # set pin numbering system to bcm # setup our output pins GPIO.setup(17,GPIO.OUT) GPIO.setup(27,GPIO.OUT) # create an infinite loop while True: # turn leds on print "lights on" GPIO.output(17,GPIO.HIGH) GPIO.output(27,GPIO.HIGH) sleep(1) # sleep 1 second # turn leds off print "lights off" GPIO.output(17,GPIO.LOW) GPIO.output(27,GPIO.LOW) sleep(1) # sleep 1 second
Download
0 formatsNo download links available.