Infra-red Remote Control

Further exploring of the libraries has brought these commands to my attention. I wasn’t sure whether it was possible to get one to communicate with another, which might be useful in the future for remote controlling robots.

To communicate between two systems via Infra-red, an infra-red diode is needed for transmission along with an infra-red receiver/demodulator.

Infra-red transmission normally takes place as a series of bursts of pulses. These pulses are sent as on/off outputs from the microcontroller at 38kHz. The bursts are then grouped to encode the signal in a similar way to morse code. It is possible to see these pulses on some mobile-phone cameras as they are often slightly sensitive to infra-red emissions. There are a number of different protocols for sending messages. The PICAXE system uses the Sony protocol, but the Raspberry Pi Pico uses the NEC protocol.

Receiving is a much more complicated affair. Many years ago I remember building a system with an infra-red photo-diode along with a reasonably involved circuit which needed a variety of capacitors, an integrated circuit and some resistors. Needless to say, at the time it was quite involved and hard to test. These days, it’s possible to get the receiver and demodulator all in one 3-pin package or, as in this case, ready mounted on a small circuit board.

In my testing, I connected the infra-red diode board to output 15 on one of my Raspberry Pi Pico boards. I wasn’t sure how to tell Microblocks which pin I had connected to, but by showing the block definition (right click) for the infra-red transmit function I was able to see that there was a pin connection variable. I noticed that the transmitter board had a Vcc connection, but it doesn’t require a connection to a power supply since it takes the output power from the pin being used. There is also a small blue LED which helps to monitor the transmission.

For the receiver, I used a ready-made module again. It has three connections which are all used. The module worked fine at the 3.3v levels offered by the Raspberry Pi Pico. The data-out pin was connected to input pin 20 on my circuit board.

Raspberry Pi Pico circuit boards with an infra-red transmitter and receiver.

The programming is straightforward once the correct inputs and outputs are set up. The receiver pin is easily set up as there is a function for that, but the transmitter pin requires the IR_transmit_device function definition to be shown (right click the function and show its definition) and then duplicate the variable setting.

I haven’t had a chance to check the range but these things are pretty efficient. In the past I have experimented with creating a lasertag system (hand-coded in assembly language!) but using a microcontroller such as these would really simplify many parts of the process. If I was concerned about range, I could use a MOSFET as a transducer driver and either an array of Infra-red diodes or a much higher-power single infra-red diode.

The program shown below just sends an alternate code 1 and code 10, while the receiver interprets this and lights one of two LEDs on outputs 2 and 3.

There’s a little video on Twitter at : https://twitter.com/IRoulson/status/1598823854641586177

Advertisement

Cheerlights on the Raspberry Pi Pico

It has been a long time since I connected with the Cheerlights system, and as we’re heading towards the winter season and Christmas, it seemed appropriate to see what could be done with a WiFi connected Raspberry Pi Pico. Cheerlights is connected to Twitter, and anyone from around the world can send a Twitter message which contains a colour name. Any device can then access this and use it in a number of ways. The current colour is shown on this webpage.

Once again, I’m working with the MicroBlocks programming language and I had noticed that they have a library for connecting to WiFi as well as functions for setting up an HTTP client.

Once the WiFi connection is made, it regularly reads the colour from this link into a variable and then uses that to light up pixels n a NeoPixel grid. To make it more interesting, I flash a random pixel at 100% brightness and then revert to 20% brightness. The current colour is read every 10 seconds or so. I’ve put a video on Twitter so that you can see its sparkly goodness.

The latest version of my program is shown below, and there is a download link at the end of this article.

The Cheerlights program can be downloaded from this link (right click and save to your own computer):

Pin Connections on the interface board

I wanted to create a board that offered as many different connections as possible. I like to create small robot models and it was really important to offer connections for H-bridges, stepper motors and a whole collection of servos. Sensors are either analogue or digital, and most of them require some sort of power connection.

As a result of all of these decisions, I’ve decided to make the connections based on the pattern set by servo connectors. On these, the centre connection is the positive (+V or Vcc) power supply, one connection is Ground (Gnd) and the final connection is the control signal. On this board, all of the connections face towards the Raspberry Pi Pico.

The pin allocations are based on those given for Microblocks running on the Raspberry Pi Pico at: https://wiki.microblocks.fun/boards/special_pins

Connection diagram for the Raspberry Pi Pico Interface Board
External Pins (Some pins can suit a variety of functions).Used For:
Pins 0-22Digital I/O only (2,3,6,7,8,9 in use for on-board functions)
Pins 0,1Serial UART : Pin 0 – TX Pin 1 – RX
Pins 4,5I2C : Pin 4 – SDA Pin 5 – SCL
Pin 10,11Suitable for an ultrasonic sensor or general I/O use.
Pins 12-19are suitable for servos and have 5v Power Available.
Pins 14-17are also available on the back for connection to a dual H-Bridge for DC motors or Bipolar/Unipolar Stepper Motor driver. A 5V Power Supply is available.
Pins 16-19SPI Pin 16 – SPI MISO Pin 17 – SPI SS Pin 18 – SPI Clock Pin 19 – SPI MOSI
Pins 20-22Digital I/O with 3.3v Power Supply
Pins 26-28Analog or digital inputs with 3.3v Power Supply
Internal Pins
Pin 23(digital output) turn on for better voltage regulation (uses a bit more power)
Pin 24(digital input) detects USB connected
Pin 25(digital output) user LED
Pin 29(analog input) temperature sensor
On-board components
Pin 2 and Pin 3On-board LEDs
Pin 6,7,8,9Tactile Switches
Pin 4,5I2C OLED Display connected to Pin 4 – SDA Pin 5 – SCL and running from 3.3v
Pin Connection List