Thursday, August 1, 2013

gpio on the Raspberry Pi

Here are some links

installing wiringpi2

using wiringpi2 for gpio

wiring table (blocked site)

Second part:

Third part:

example from part 1

import wiringpi2 as wiringpi  
from time import sleep       # allows us a time delay  
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  
    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)  
            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 

Pi hardware info page:

info on the BCM2835 GPIO's

Good website for using GPIO with the RPI

Broadcom Arm peripheral spec:

No comments:

Post a Comment