The first blink
Three wires, no library, and a sketch that turns the infrared LED on for a second and off for a second. You will not see it. The red LED beside it shows the transistor switching, and a phone camera often shows the infrared itself as a faint violet glow. VCC goes to 5V; SIGNAL to GPIO 6 on an ESP32-S3, GPIO 22 on an ESP32, D3 on an Uno, GP17 on a Pico.
Three wires
GND to GND. VCC to 5V, or VBUS on a Pico: it only feeds the LEDs, so 5 V is safe on a 3.3 V board and gives the most light. SIGNAL to the pin this book uses throughout. NC stays unconnected.
The pins are the IR handbook's send pins, so its receiver sketches line up with this block. None of them is a strapping pin, and that matters here in an unusual way. SIGNAL is 1 kΩ and a transistor's base to GND, which pulls a pin down to under a volt. On an ESP32-S3's GPIO 0, against the dev board's 10 kΩ BOOT pull-up, that is about 0.94 V: not a level the chip promises to read as HIGH, so it may start in its download mode, with the LEDs lit through the reset.
The sketch
pinMode(IR_PIN, OUTPUT) and digitalWrite(IR_PIN, LOW) first, because
nothing on the board holds the transistor off. Then the loop: HIGH for a
second, LOW for a second, a line to the serial monitor each time.
What you should see
At 115200 the serial monitor prints on and off a second apart, and the
small red LED blinks with it. The infrared LED does not change at all to
your eye.
Now look at it through a phone camera, in a dim room, straight into the lens. Many cameras show 940 nm as a faint violet glow that comes and goes with the red LED. Some filter infrared out almost completely; try another camera before suspecting the block. If the red LED blinks, the infrared LED is on: they share the transistor.
The code
No library. digitalWrite HIGH turns the transistor on and both LEDs light; LOW turns them off, once a second, with a line to the serial monitor each time. Change IR_PIN to the pin you wired SIGNAL to.
/*
Infrared Transmitter - first blink TK63 / /p/tk63
Wiring. Count from the square pad on the TinkerBlock board, parts
up, header at the bottom:
GND -> GND
VCC -> 5V (VBUS on a Pico) for full range; 3V3 works, shorter.
VCC only feeds the two LEDs, so 5V is safe on any board.
NC -> nothing (unconnected on the board)
SIGNAL -> GPIO 6 on an ESP32-S3, GPIO 22 on an ESP32,
D3 on an Uno, GP17 on a Raspberry Pi Pico
Arduino IDE
Tools > Board your board, e.g. ESP32S3 Dev Module
Tools > Port the one that appears when you plug in
Tools > USB CDC On Boot Enabled (ESP32-S3 only)
No library needed.
Serial Monitor 115200
*/
// The pin SIGNAL is wired to.
// Uno: 3. ESP32: 22. ESP32-S3: 6. Pico: 17.
const int IR_PIN = 6;
void setup() {
// LOW first: nothing on the board holds the transistor off.
pinMode(IR_PIN, OUTPUT);
digitalWrite(IR_PIN, LOW);
Serial.begin(115200);
}
void loop() {
// HIGH turns the transistor on: both LEDs light.
digitalWrite(IR_PIN, HIGH);
Serial.println("on: the red LED is lit; look through a camera");
delay(1000);
digitalWrite(IR_PIN, LOW);
Serial.println("off");
delay(1000);
}setup() drives the pin LOW before anything else, because nothing on the board holds the transistor off. The sketch compiles for an ESP32-S3 and an Uno.
View on GitHub · blocks/tk63-ir-transmitter/arduino/ir_first_blink/ir_first_blink.ino @ v1.5The same blink in MicroPython: Pin(IR_PIN, Pin.OUT, value=0) starts it LOW, then value(1) and value(0) a second apart. No library to install.
"""
Infrared Transmitter - first blink, MicroPython TK63 / /p/tk63
Wiring. Count from the square pad on the TinkerBlock board, parts
up, header at the bottom:
GND -> GND
VCC -> 5V (VBUS on a Pico) for full range; 3V3 works, shorter
NC -> nothing (unconnected on the board)
SIGNAL -> GPIO 6 on an ESP32-S3, GPIO 22 on an ESP32,
GP17 on a Raspberry Pi Pico
Thonny
Run > Configure interpreter MicroPython (ESP32) or
MicroPython (Raspberry Pi Pico)
"""
import time
from machine import Pin
# The GPIO number SIGNAL is wired to. ESP32: 22. ESP32-S3: 6. Pico: 17.
IR_PIN = 6
ir = Pin(IR_PIN, Pin.OUT, value=0) # LOW: both LEDs off
while True:
ir.value(1) # transistor on: both LEDs light
print("on: the red LED is lit; look through a camera")
time.sleep(1)
ir.value(0)
print("off")
time.sleep(1)The pin numbers are GPIO numbers: 6 on an ESP32-S3, 22 on an ESP32, 17 on a Pico. Stop it with Ctrl-C; the LEDs stay as they were at that moment.
View on GitHub · blocks/tk63-ir-transmitter/micropython/ir_first_blink.py @ v1.5When it does not work
Then the block works: the red LED is on the infrared LED's transistor. Many phone cameras filter infrared, some completely. Try another camera, the front one included, in a dim room, looking straight down into the lens.
The transistor never switched or the LEDs have no supply. Count from the square pad: GND, VCC, NC, SIGNAL. Check IR_PIN is the pin SIGNAL is on, and that the wire is not on NC, which is connected to nothing.
Set Tools > USB CDC On Boot to Enabled and upload again. Without it the S3's USB port does not bring up a serial port at boot, so the sketch runs, and blinks, with nowhere to print.
Nothing on the board holds the transistor off, so it follows the pin during reset. A pin that floats or is pulled up then can light both LEDs until setup() sets it LOW. It does no harm; on a strapping pin it can also change how the board starts, which is why this book avoids them.
Why a steady light reaches no remote-control receiver, and the 38 kHz that does.
A carrier the TK15 hears →Edit this page — content/books/ir-transmitter/the-first-blink.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Infrared Transmitter
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.