Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import time
- import pigpio # http://abyz.co.uk/rpi/pigpio/
- GPIO=4
- SWITCH1 = 17 #(P11)
- pi = pigpio.pi() # Connect to local Pi.
- pi.set_mode(GPIO, pigpio.OUTPUT) # Set GPIO as an output.
- pi.set_mode(17, pigpio.INPUT) #Set Pin 11 as input
- pi.set_pull_up_down(17, pigpio.PUD_UP) #with pull-up
- pi.wave_add_new() # Clear any leftover data.
- pi.wave_add_serial(GPIO, 31250, chr(0x90)+chr(0x43)+chr(0x40))
- wid = pi.wave_create() # Create wave from added data, get id.
- while pi.read(17) == 1: #Wait while switch is not pressed
- time.sleep(0.1)
- for i in range(1):
- pi.wave_send_once(wid) # Transmit wave data.
- while pi.wave_tx_busy(): # Wait for wave end, then repeat.
- time.sleep(0.01)
- pi.wave_delete(wid) # Delete wave to release used resources.
- pi.stop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement