parent
77ce6cd9eb
commit
6577b7e592
@ -1,14 +1,14 @@
|
|||||||
import wiringpi2
|
import wiringpi
|
||||||
PIN_TO_SENSE = 23
|
PIN_TO_SENSE = 23
|
||||||
|
|
||||||
def gpio_callback():
|
def gpio_callback():
|
||||||
print "GPIO_CALLBACK!"
|
print "GPIO_CALLBACK!"
|
||||||
|
|
||||||
wiringpi2.wiringPiSetupGpio()
|
wiringpi.wiringPiSetupGpio()
|
||||||
wiringpi2.pinMode(PIN_TO_SENSE, wiringpi2.GPIO.INPUT)
|
wiringpi.pinMode(PIN_TO_SENSE, wiringpi.GPIO.INPUT)
|
||||||
wiringpi2.pullUpDnControl(PIN_TO_SENSE, wiringpi2.GPIO.PUD_UP)
|
wiringpi.pullUpDnControl(PIN_TO_SENSE, wiringpi.GPIO.PUD_UP)
|
||||||
|
|
||||||
wiringpi2.wiringPiISR(PIN_TO_SENSE, wiringpi2.GPIO.INT_EDGE_BOTH, gpio_callback)
|
wiringpi.wiringPiISR(PIN_TO_SENSE, wiringpi.GPIO.INT_EDGE_BOTH, gpio_callback)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
wiringpi2.delay(2000)
|
wiringpi.delay(2000)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
# Demonstrates use of Arduino-like delay function
|
# Demonstrates use of Arduino-like delay function
|
||||||
import wiringpi2
|
import wiringpi
|
||||||
print 'Hello World'
|
print 'Hello World'
|
||||||
wiringpi2.delay(1500) # Delay for 1.5 seconds
|
wiringpi.delay(1500) # Delay for 1.5 seconds
|
||||||
print 'Hi again!'
|
print 'Hi again!'
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander )
|
# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander )
|
||||||
import wiringpi2
|
import wiringpi
|
||||||
|
|
||||||
pin_base = 65
|
pin_base = 65
|
||||||
i2c_addr = 0x20
|
i2c_addr = 0x20
|
||||||
pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]
|
pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]
|
||||||
|
|
||||||
wiringpi2.wiringPiSetup()
|
wiringpi.wiringPiSetup()
|
||||||
wiringpi2.mcp23017Setup(pin_base,i2c_addr)
|
wiringpi.mcp23017Setup(pin_base,i2c_addr)
|
||||||
|
|
||||||
for pin in pins:
|
for pin in pins:
|
||||||
wiringpi2.pinMode(pin,1)
|
wiringpi.pinMode(pin,1)
|
||||||
wiringpi2.digitalWrite(pin,1)
|
wiringpi.digitalWrite(pin,1)
|
||||||
# wiringpi2.delay(1000)
|
# wiringpi.delay(1000)
|
||||||
# wiringpi2.digitalWrite(pin,0)
|
# wiringpi.digitalWrite(pin,0)
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
# Pulsates an LED connected to GPIO pin 1 with a suitable resistor 4 times using softPwm
|
# Pulsates an LED connected to GPIO pin 1 with a suitable resistor 4 times using softPwm
|
||||||
# softPwm uses a fixed frequency
|
# softPwm uses a fixed frequency
|
||||||
import wiringpi2
|
import wiringpi
|
||||||
|
|
||||||
OUTPUT = 1
|
OUTPUT = 1
|
||||||
|
|
||||||
PIN_TO_PWM = 1
|
PIN_TO_PWM = 1
|
||||||
|
|
||||||
wiringpi2.wiringPiSetup()
|
wiringpi.wiringPiSetup()
|
||||||
wiringpi2.pinMode(PIN_TO_PWM,OUTPUT)
|
wiringpi.pinMode(PIN_TO_PWM,OUTPUT)
|
||||||
wiringpi2.softPwmCreate(PIN_TO_PWM,0,100) # Setup PWM using Pin, Initial Value and Range parameters
|
wiringpi.softPwmCreate(PIN_TO_PWM,0,100) # Setup PWM using Pin, Initial Value and Range parameters
|
||||||
|
|
||||||
for time in range(0,4):
|
for time in range(0,4):
|
||||||
for brightness in range(0,100): # Going from 0 to 100 will give us full off to full on
|
for brightness in range(0,100): # Going from 0 to 100 will give us full off to full on
|
||||||
wiringpi2.softPwmWrite(PIN_TO_PWM,brightness) # Change PWM duty cycle
|
wiringpi.softPwmWrite(PIN_TO_PWM,brightness) # Change PWM duty cycle
|
||||||
wiringpi2.delay(10) # Delay for 0.2 seconds
|
wiringpi.delay(10) # Delay for 0.2 seconds
|
||||||
for brightness in reversed(range(0,100)):
|
for brightness in reversed(range(0,100)):
|
||||||
wiringpi2.softPwmWrite(PIN_TO_PWM,brightness)
|
wiringpi.softPwmWrite(PIN_TO_PWM,brightness)
|
||||||
wiringpi2.delay(10)
|
wiringpi.delay(10)
|
||||||
|
|||||||
@ -1,18 +1,18 @@
|
|||||||
# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander )
|
# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander )
|
||||||
import wiringpi2
|
import wiringpi
|
||||||
|
|
||||||
pin_base = 65
|
pin_base = 65
|
||||||
i2c_addr = 0x20
|
i2c_addr = 0x20
|
||||||
i2c_addr_2 = 0x21
|
i2c_addr_2 = 0x21
|
||||||
#pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]
|
#pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]
|
||||||
|
|
||||||
wiringpi2.wiringPiSetup()
|
wiringpi.wiringPiSetup()
|
||||||
wiringpi2.mcp23017Setup(pin_base,i2c_addr)
|
wiringpi.mcp23017Setup(pin_base,i2c_addr)
|
||||||
wiringpi2.mcp23017Setup(pin_base+16,i2c_addr_2)
|
wiringpi.mcp23017Setup(pin_base+16,i2c_addr_2)
|
||||||
|
|
||||||
#for pin in pins:
|
#for pin in pins:
|
||||||
for pin in range(65,96):
|
for pin in range(65,96):
|
||||||
wiringpi2.pinMode(pin,1)
|
wiringpi.pinMode(pin,1)
|
||||||
wiringpi2.digitalWrite(pin,1)
|
wiringpi.digitalWrite(pin,1)
|
||||||
# wiringpi2.delay(1000)
|
# wiringpi.delay(1000)
|
||||||
# wiringpi2.digitalWrite(pin,0)
|
# wiringpi.digitalWrite(pin,0)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import wiringpi2 as wiringpi
|
import wiringpi
|
||||||
io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
|
io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
|
||||||
io.piGlowSetup()
|
io.piGlowSetup()
|
||||||
io.piGlowLeg(1,100)
|
io.piGlowLeg(1,100)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import wiringpi2 as wiringpi
|
import wiringpi
|
||||||
io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
|
io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
|
||||||
print io.digitalRead(1)
|
print io.digitalRead(1)
|
||||||
print io.analogRead(1)
|
print io.analogRead(1)
|
||||||
|
|||||||
Loading…
Reference in new issue