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_b...
Tutorial 3 Download: http://www.modmypi.com/download/youtu...
View Tutorial Online: https://www.modmypi.com/blog/youtube-...
** 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
In questa pagina del sito puoi guardare il video online Raspberry Pi Workshop Kit Tutorials – 3 LED Blink della durata di ore minuti seconda in buona qualità , che l'utente ha caricato HiPi io 15 giugno 2017, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 2,462 volte e gli è piaciuto 17 spettatori. Buona visione!