Here are some links
installing wiringpi2
http://raspi.tv/how-to-install-wiringpi2-for-python-on-the-raspberry-pi#install
using wiringpi2 for gpio
http://raspi.tv/2013/how-to-use-wiringpi2-for-python-on-the-raspberry-pi-in-raspbian
wiring table (blocked site)
Second part:
http://raspi.tv/2013/how-to-use-wiringpi2-for-python-with-pull-ups-or-pull-downs-and-pwm
Third part:
http://raspi.tv/2013/using-the-mcp23017-port-expander-with-wiringpi2-to-give-you-16-new-gpio-ports-part-3
example from part 1
import wiringpi2 as wiringpi
from time import sleep # allows us a time delay
wiringpi.wiringPiSetupGpio()
wiringpi.pinMode(24, 1) # sets GPIO 24 to output
wiringpi.digitalWrite(24, 0) # sets port 24 to 0 (0V, off)
wiringpi.pinMode(25, 0) # sets GPIO 25 to input
try:
while True:
if wiringpi.digitalRead(25): # If button on GPIO25 pressed
wiringpi.digitalWrite(24, 1) # switch on LED. Sets port 24 to 1 (3V3, on)
else:
wiringpi.digitalWrite(24, 0) # switch off LED. Sets port 24 to 0 (0V, off)
sleep(0.05) # delay 0.05s
finally: # when you CTRL+C exit, we clean up
wiringpi.digitalWrite(24, 0) # sets port 24 to 0 (0V, off)
wiringpi.pinMode(24, 0) # sets GPIO 24 back to input Mode
# GPIO 25 is already an input, so no need to change anything
x
Pi hardware info page:
http://elinux.org/RPi_Hardware#Schematic_.2F_Layout
info on the BCM2835 GPIO's
http://elinux.org/RPi_BCM2835_GPIOs
Good website for using GPIO with the RPI
http://wiringpi.com/
Broadcom Arm peripheral spec:
http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
No comments:
Post a Comment