Raspberry Pi Workshop Kit Tutorials – 3 LED Blink

Veröffentlicht am: 15 Juni 2017
auf dem Kanal: HiPi io
2,462
17

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


Auf dieser Seite können Sie das Online-Video Raspberry Pi Workshop Kit Tutorials – 3 LED Blink mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer HiPi io 15 Juni 2017 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 2,462 Mal angesehen und es wurde von 17 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!