Starting RPi gpio output.
Here is a little project I just started on. Have done a lot of work with a legacy Pc port. In fact, a lot of interfacing to different devices have been documented in my blogs. One thing you have to be careful of is that the pinouts vary between the different Raspberry Pi models.
Here is the wiring diagram for the original RPi and for the RPi zero. An article recommends 470 ohm resisters.
Not a fan of python, but there is a lot code that can be used.
Python code. (railroad track warning lights.)
--------------------
#Import libraries
import RPi.GPIO AS GPIO
import time
#set gpio numbering mode and defind pins
GPIO.setwarnings(False)
GPIO.setmode)GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(11, GPIO.OUT
#blink the leds
for x in range(0.10):
GPIO output(7, True)
GPIO output(11, False)
time.sleep(.5)
GPIO output(7, False)
GPIO output(11, True)
time.sleep(.5)
# cleanup the gpio pins before ending
GPIO output(11, False)
GPIO output(7, False)
GPIO.cleanup
Comments
Post a Comment