CircuitPython: PulseIO and cloning an IR remote control with Tony D!
Live stream to http://twitch.tv/adafruit showing the pulseio module in CircuitPython and how to use it with an IR receiver and IR LED to clone a remote control. Learn a bit about how IR remotes work and how CircuitPython can capture and generate their signals.
Links and hardware mentioned in the video:
- Feather M0 Express guide (go here to learn about loading CircuitPython on this board): https://learn.adafruit.com/adafruit-feather-m0-express-designed-for-circuit-python-circuitpython/overview
- IR LED: https://www.adafruit.com/product/387 (don't forget you need a ~200-500 ohm resistor too)
- IR receiver: https://www.adafruit.com/product/157
- Generic remote control: https://www.adafruit.com/product/389
- NEC remote protocol: http://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol#
- CircuitPython PulseIO documentation: http://circuitpython.readthedocs.io/en/latest/shared-bindings/pulseio/__init__.html
Recap of wiring and code in video:
- IR receiver right most pin (with bump facing you) to board 5V power (USB on Feather boards plugged into computer).
- IR receiver middle pin to board ground.
- IR receiver left most pin to board D6.
- IR LED anode (longer leg) to board D11
- IR LED cathode (shorter leg) to one side of 220 ohm resistor
- Other side of 220 ohm resistor to board ground
Capture signal with code:
import board
import pulseio
ir_read = pulseio.PulseIn(board.D6, maxlen=100, idle_state=True)
Press remote control button with it facing the IR receiver. Now copy the value out to an array object in a specific 16-bit format:
import array
on_command = array.array('H', [ir_read[x] for x in range(len(ir_read))])
Finally create a PWM output and PulseOut object to play back the on command above:
ir_led = pulseio.PWMOut(board.D11, frequency=38000, duty_cycle=2**15)
ir_send = pulseio.PulseOut(ir_led)
ir_send.send(on_command)
Acknowledgements:
- Music: bartlebeats
- Intro shuttle footage: NASA
- Intro fonts: Typodermic
- Intro inspiration: Mr. Wizards's World
- Matrix background: cool-retro-term & cmatrix
-----------------------------------------
Visit the Adafruit shop online - http://www.adafruit.com
Subscribe to Adafruit on YouTube: http://adafru.it/subscribe
Join our weekly Show & Tell on G+ Hangouts On Air: http://adafru.it/showtell
Watch our latest project videos: http://adafru.it/latest
New tutorials on the Adafruit Learning System: http://learn.adafruit.com/
Music by bartlebeats: http://soundcloud.com/bartlebeats
-----------------------------------------