Infrared Receive and Transmit with Circuit Playground Express

Similar documents
New Year Countdown Clock with Circuit Playground Express

Make It Sound. Created by Mike Barela. Last updated on :10:45 PM UTC

EDUCATIONAL TUTOR FOR MENTALLY DISABLE STUDENTS

User Manual Wireless HD AV Transmitter & Receiver Kit

WDP02 Wireless FHD Kit User Manual

RF4432 wireless transceiver module

6.111 Project Proposal IMPLEMENTATION. Lyne Petse Szu-Po Wang Wenting Zheng

Digital Circuits 4: Sequential Circuits

Character LCDs. Created by lady ada. Last updated on :47:43 AM UTC

Full HD Multi-Channel Expandable Wireless HDMI Gateway Extender

RF4432F27 wireless transceiver module

Multi-Channel Wireless HDMI Extender Kit 1080p - 50m User's Guide

CVM-WM300. UHF Wireless Microphone USER MANUAL

Dual Antenna Wireless Multi-Channel Expandable HDMI Extender Installation Guide

Interaction of Infrared Controls And Fluorescent Lamp/Ballast Systems In Educational Facilities

Wireless Multi-Format input Transmitter to HDMI Receiver Box ID # 718

User Manual. AVA-EX11-70TX AVA-EX11-70RX 70m HDMI Extender. Version: V1.0.2

HDMI Wireless Extender

HDMI over IP EXTENDER

B. The specified product shall be manufactured by a firm whose quality system is in compliance with the I.S./ISO 9001/EN 29001, QUALITY SYSTEM.

PI MANUFACTURING Powered by Infinite Solutions

CWHDI-TX2 & RX2 Wireless Multi-Format input Transmitter to HDMI Receiver Box

HDBaseT HDMI Extender over CAT5e/6/7 with IR - 70m

CH-2538TXWPKD 4K UHD HDMI/VGA over HDBaseT Wallplate Transmitter. CH-2527RX 4K UHD HDMI over HDBaseT Receiver. Operation Manual

INTERNATIONAL TELECOMMUNICATION UNION GENERAL ASPECTS OF DIGITAL TRANSMISSION SYSTEMS PULSE CODE MODULATION (PCM) OF VOICE FREQUENCIES

OPERATION MANUAL HDMIWIRELESS

Therefore we need the help of sound editing software to convert the sound source captured from CD into the required format.

The membership approved Carl Bulger s motion that we make no changes to the Constitution and By-Laws.

Circuit Playground Hot Potato

Wireless 1080P HDMI Video Kit - Mid-Range

FV400 DIGITAL TV RECEIVER WITH MODULATOR INSTRUCTION MANUAL

USER MANUAL. KW-11T Wireless High Definition Transmitter. KW-11R Wireless High Definition Receiver MODELS: P/N: Rev 9

USER MANUAL. KW-11T Wireless High Definition Transmitter. KW-11R Wireless High Definition Receiver MODELS: P/N: Rev 5

Quick Start Guide. Wireless TV Connection with Dongle. GWHDKITD PART NO. Q1504-b

SSTV Transmission Methodology

HDMI WIRELESS EXTENDER/ RECEIVER. Vanco Part Number: HDWIRKIT HDWIR-RX. Technical Support

Laboratory 4. Figure 1: Serdes Transceiver

HDMI Over Mains Power with IR AR-1903 User Manual

Design and Implementation of Timer, GPIO, and 7-segment Peripherals

C-MAX. TSG200 Time signal generator TSG200. Time Signal Generator. Manual TSG200. RF Technology Specialist. Version. Revision. SPEC No.

Pattern Based Attendance System using RF module

LINK-MI LM-WHD05B. Wireless HDMI AV Transmission System. User Manual

Quick Start Guide. Wireless TV Connection with Dongle. GWHDKITD PART NO. Q1504

EarStudio: Analog volume control. The importance of the analog volume control

HDMI Extender Set Full HD, 130 m

AVS50 USER GUIDE. 2.4GHz Audio/Video Sender System - AVS50

ORPHEUS ZERO U S E R M A N U A L

MULTIDYNE INNOVATIONS IN TELEVISION TESTING & DISTRIBUTION DIGITAL VIDEO, AUDIO & DATA FIBER OPTIC MULTIPLEXER TRANSPORT SYSTEM

VGA & Stereo Audio CAT5 Extender With Chainable Output ITEM NO.: VE10DAL, VE02ALR, VE02DALS

BER MEASUREMENT IN THE NOISY CHANNEL

ANTENNAS, WAVE PROPAGATION &TV ENGG. Lecture : TV working

CAP240 First semester 1430/1431. Sheet 4

VGA, Audio & RS-232 Serial with IR Pass-Thru over Single CAT5 /RJ45 Extender Kit

AMEK SYSTEM 9098 DUAL MIC AMPLIFIER (DMA) by RUPERT NEVE the Designer

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

N5264A. New. PNA-X Measurement Receiver. Jim Puri Applications Specialist March Rev. Jan Page 1

In total 2 project plans are submitted. Deadline for Plan 1 is on at 23:59. The plan must contain the following information:

Transmitter Installation and Operation

Xanura Programmeer Unit Type PUX

Super-Doubler Device for Improved Classic Videogame Console Output

Minutes of the Baseband IR PHY Ad-Hoc Group

MONOPRICE. BitPath AV HDMI Extender over Single Cat6 Cable, 120m. User's Manual P/N 16228

M5-H002. Multiview T-35. DVB-T to PAL / 5 channels on all TV s

Exercise 1-2. Digital Trunk Interface EXERCISE OBJECTIVE

PLV-Z2 ROLL THE FILM FOR THE FUTURE!

AITech ProA/V Media Extender Mini. User Manual

HDMI Wireless Transmitter 200m. User Manual. Thank you for purchasing this product. For optimum performance and safety, please read the

Department of Communication Engineering Digital Communication Systems Lab CME 313-Lab

Netzer AqBiSS Electric Encoders

LINK EXT40-4KECO. 4K 40m HDMI Extender. User Manual. Version: V1.0.1

Since the early 80's, a step towards digital audio has been set by the introduction of the Compact Disc player.

User Manual CS-HDBTLPOER m HDBaseT Extender with Bi-directional PoE. Version: V1.0.0

CS 254 DIGITAL LOGIC DESIGN. Universal Asynchronous Receiver/Transmitter

Artificial Intelligence in Tele-Vision

Quick Start Guide Expandable Wireless TV Connection Receiver

Setting up the Setting up the Dragonfly 1 v June

PCM1024Z format: What's Known? W.Pasman 11/11/3

HDMI 4K HDBaseT Extender Over Single Cat5e/6 Cable with IR Control - 70m User Reference Guide

Video Transmission. Thomas Wiegand: Digital Image Communication Video Transmission 1. Transmission of Hybrid Coded Video. Channel Encoder.

ABCD. Application Note No Reeve Engineers. Transmission Level Point. 1. Introduction. 2. Application of the TLP

Digital Representation

HDMI over Wireless Extender

MONOPRICE. BitPath AV 4K HDMI Wireless Transmitter & Receiver Kit, 200m. User's Manual P/N 16223

Team Members: Erik Stegman Kevin Hoffman

G200 Wireless AV Sender User Guide

M1 OSCILLOSCOPE TOOLS

HDMI Extender over Cat5e/Cat6 (HD BaseT) User manual. VER: 1.1s

MONOPRICE. BitPath AV SDI Wireless Transmitter & Receiver Kit, 200m. User's Manual P/N 16225


I. Introduction. II. Features

MONOPRICE. BitPath AV 4K 1X4 HDMI Splitter Extender over Single Cat6 with IR, 120m. User's Manual P/N 16286

1 Unpack. Taking the TV Out of the Box. Included in this Box. Remote Control. Stand Parts and Cables. Also included

JASON Version First of all, why the name Jason? Well, you all know the program Argo...

16-Bit DSP Interpolator IC For Enhanced Feedback in Motion Control Systems

CLR-HDMI-LLT & CLR-HDMI-LLR

VIDEO GRABBER. DisplayPort. User Manual

This module senses temperature and humidity. Output: Temperature and humidity display on serial monitor.

DIGITAL SET TOP BOX STB 7017 INSTRUCTION MANUAL

HDMI Over IP Extender

ASYNCHRONOUS COUNTER CIRCUITS

Transcription:

Infrared Receive and Transmit with Circuit Playground Express Created by Kattni Rembor Last updated on 2018-08-22 04:10:35 PM UTC

Guide Contents Guide Contents Overview IR Test with Remote Mini Remote Control IR from CPX to CPX Using IR as an Input 2 3 4 4 6 8 Page 2 of 9

Overview The Circuit Playground Express is an amazing little board with tons of sensors and things built in, including an infrared transmitter and an infrared receiver. This guide will show you how to use CircuitPython to send simple messages between two Circuit Playground Expresses using infrared! This guide expects that you have two Circuit Playground Expresses, as we will be using IR to communicate between them. You can get wireless communications without antennas, pairing or passwords. Infrared (IR) is invisible to the naked eye which makes it great for wireless communication. IR communication is line-ofsight (the sensor must be pointed towards the receiver) and has about a 10-20 meter range (optimally). It's good for sending short amounts of data. IR remotes use infrared for communicating with their targets, for example your television. For more information about IR, check out this article (https://adafru.it/bvo). The IR transmitter and receiver on the Circuit Playground Express can be found near the center of the board. The transmitter is labeled TX and is on the left side of the reset button, to the right of button A. The receiver is labeled RX and is on the right side of the reset button, to the left of button B. Page 3 of 9

IR Test with Remote The first thing we're going to do is test IR receive with a NEC remote. NEC is a electronics manufacturer, one of several, that defined their own IR coding scheme which has also been used by other folks in products. You can try any remotes you have sitting around the house (although they might use an encoding other than NEC). We have this handy little one (https://adafru.it/xck) available in the store which we're going to use for our test. Mini Remote Control $4.95 IN STOCK ADD TO CART Copy the following code to your code.py: import pulseio import board import adafruit_irremote # Create a 'pulseio' input, to listen to infrared signals on the IR receiver pulsein = pulseio.pulsein(board.ir_rx, maxlen=120, idle_state=true) # Create a decoder that will take pulses and turn them into numbers decoder = adafruit_irremote.genericdecode() while True: pulses = decoder.read_pulses(pulsein) try: # Attempt to convert received pulses into numbers received_code = decoder.decode_bits(pulses, debug=false) except adafruit_irremote.irnecrepeatexception: # We got an unusual short code, probably a 'repeat' signal # print("nec repeat!") continue except adafruit_irremote.irdecodeexception as e: # Something got distorted or maybe its not an NEC-type remote? # print("failed to decode: ", e.args) continue print("nec Infrared code received: ", received_code) if received_code == [255, 2, 255, 0]: print("received NEC Vol-") if received_code == [255, 2, 127, 128]: print("received NEC Play/Pause") if received_code == [255, 2, 191, 64]: print("received NEC Vol+") We create the pulsein object to listen for infrared signals on the IR receiver. Then we create the decoder object to take Page 4 of 9

the pulses and turn them into numbers. Then we take the decoder object and attempt to convert the received pulses into numbers. There's two errors we check for and tell the code to continue running if they're encountered. One possible decoding error is an unusually short code, which is probably an NEC repeat signal. If you hold down a remote button, the remote control may 'save effort and time' by sending a short code that means "keep doing that". For example, holding down the volume button to quickly increase or decrease the volume on a TV. We don't handle those repeat codes in this project, we're only looking for unique button presses The second possible decoding error is when it fails to decode, which can mean the signal got distorted or you're not using a NEC remote. Then we print the code we receive from the remote. If we receive the codes from the first three buttons on the remote, we print which button was pressed. If you're using your own remote, you can check the serial console to find the codes you're receiving. They'll be printed after NEC Infrared code received:. Then, you can change code.py to reflect the specific button codes for your remote. Page 5 of 9

IR from CPX to CPX Your Circuit Playground Express can both transmit and receive IR signals! There is an example where each button on the CPX sends a different signal. We've emulated the volume up and volume down buttons on the Adafruit NEC remote since the receive code is already looking for those signals. So, the program be sending four bytes of data with each button press for the other CPX to receive and decode. Why send four bytes instead of one? IR communication is messy, and often gets mixed up with flickering lights in the room, or maybe something blocking the photons. If you send only one byte, you run the risk of a signal being misinterpreted as some other signal. By requiring and checking for four digits, your chance of getting a mistaken message is less likely. Why not more than four? If the message is too long, it would take a long time to send, and use more power. Four bytes are defined for the NEC standard - it's a nice trade-off between too-short and too-long. You'll need two Circuit Playground Expresses for this example. You should still have the code from the previous example (https://adafru.it/bvp) on the first CPX. Copy the following code into your code.py on the second CPX: import time from adafruit_circuitplayground.express import cpx import adafruit_irremote import pulseio import board # Create a 'pulseio' output, to send infrared signals on the IR transmitter @ 38KHz pwm = pulseio.pwmout(board.ir_tx, frequency=38000, duty_cycle=2 ** 15) pulseout = pulseio.pulseout(pwm) # Create an encoder that will take numbers and turn them into NEC IR pulses encoder = adafruit_irremote.generictransmit(header=[9500, 4500], one=[550, 550], zero=[550, 1700], trail=0) while True: if cpx.button_a: print("button A pressed! \n") cpx.red_led = True encoder.transmit(pulseout, [255, 2, 255, 0]) cpx.red_led = False # wait so the receiver can get the full message time.sleep(0.2) if cpx.button_b: print("button B pressed! \n") cpx.red_led = True encoder.transmit(pulseout, [255, 2, 191, 64]) cpx.red_led = False time.sleep(0.2) We create a pulseio output to send infrared signals from the IR transmitter at 38KHz. Then we create an encoder that will take the numbers we're sending and turn them into NEC IR pulses. The arguments we pass into the adafruit_irremote.generictransmit line is what lets the irremote library know how to encode the 4 bytes into NEC remote data. There's a 9.5ms pulse high followed by a 4.5ms pulse low to let the receiver know data is coming. Then 550us+550us pulse pairs for a '1' value and 550us+1700us pulse pair for a '0' value. Page 6 of 9

header=[9500, 4500], one=[550, 550], zero=[550, 1700], trail=0 Inside our loop, we check to see if each button is pressed. When a button is pressed, we print a message to the serial console. Then, we turn on the red LED, send our 4 byte data signal, and turn the red LED off. Then we wait 0.2 seconds to give the receiver a chance to receive the full message. Connect both Circuit Playground Expresses to the serial console to see the associated serial output. We've overlapped the windows side-by-side to show the serial output from both boards next to each other. You can see exactly what happens on the left when you press a button on the transmitting board, and on the right after the signal is received by the receiving board. If you'd like to emulate your own remote, simply change the IR codes in the code.py above to match the changes you made in the last example. It works as long as you're transmitting the same code that the receiving board is expecting! Page 7 of 9

Using IR as an Input We've shown how to send and receive IR signals from Circuit Playground Express to Circuit Playground Express. You can use those signals as an input to trigger events on the receiving CPX. So, let's do something fun with it. It's time to light it up and make some noise! You'll need two Circuit Playground Expresses for this example. Copy the following code to code.py on the CPX currently receiving signals. The transmission code.py will remain the same from the previous page import pulseio import board import adafruit_irremote from adafruit_circuitplayground.express import cpx # Create a 'pulseio' input, to listen to infrared signals on the IR receiver pulsein = pulseio.pulsein(board.ir_rx, maxlen=120, idle_state=true) # Create a decoder that will take pulses and turn them into numbers decoder = adafruit_irremote.genericdecode() while True: pulses = decoder.read_pulses(pulsein) try: # Attempt to convert received pulses into numbers received_code = decoder.decode_bits(pulses, debug=false) except adafruit_irremote.irnecrepeatexception: # We got an unusual short code, probably a 'repeat' signal # print("nec repeat!") continue except adafruit_irremote.irdecodeexception as e: # Something got distorted or maybe its not an NEC-type remote? # print("failed to decode: ", e.args) continue print("nec Infrared code received: ", received_code) if received_code == [255, 2, 255, 0]: print("button A signal") cpx.pixels.fill((130, 0, 100)) if received_code == [255, 2, 191, 64]: print("button B Signal") cpx.pixels.fill((0, 0, 0)) cpx.play_tone(262, 1) The beginning of this code is the same as the test with the remote. We create the pulsesio and decoder objects, wait to receive the signals, and attempt to decode them. Then we print the IR code received. We check for the button presses like before as well. However, instead of simply print()ing to the serial output, we've added something more fun! If we receive the IR code now associated with button A, we print Button A signal, and turn all the NeoPixel LEDs purple! If we receive the IR code now associated with button B, we print Button B signal, turn all of the LEDs off, and play a 262Hz tone! Page 8 of 9

We've put the two windows together again to show the associated print statements from each board. The transmitting board output is on the left and the receiving output is on the right. You can do all kinds of things by adding code to these if blocks, such as, move a servo, play a wave file, change LED animations, or print a special message to the serial output. The possibilities are endless. Pick something and give it a try! Last Updated: 2018-08-22 04:10:29 PM UTC Page 9 of 9