Worked example: two_led_thermo
A minimal cuewire rig in two LEDs, one thermistor, and a camera TTL trigger. Walks a 105-second phasing protocol while streaming 10 Hz CSV telemetry to a log file.
Hardware
Function |
Pin |
Notes |
|---|---|---|
LED A |
D9 |
series resistor (220 Ω) to GND |
LED B |
D10 |
series resistor to GND |
Camera TTL |
D11 |
HIGH = recording |
NTC thermistor |
A0 |
5 V — 10 kΩ — A0 — NTC — GND |
The thermistor branch matches a 10 kΩ-at-25 °C, β-3950 NTC bead;
adjust THERM_R25 and THERM_BETA in
thermistor.ino for other parts.
Protocol
Nine integer commands plus the 1337 handshake:
Method |
Integer |
Effect |
|---|---|---|
|
|
|
|
|
start 10 Hz telemetry |
|
|
stop telemetry |
|
|
LED A on |
|
|
LED A off |
|
|
LED B on |
|
|
LED B off |
|
|
camera TTL HIGH |
|
|
camera TTL LOW |
Telemetry frame, one CSV line every 100 ms:
>clock_s,temp_C,led_a,led_b,cam<
Phase machine
run_protocol() walks five phases (105 s total):
camera ON
├── 30 s PRE_STIM both LEDs off
├── 15 s LIGHT_A A on, B off
├── 15 s LIGHT_B A off, B on
├── 15 s LIGHT_AB A on, B on
└── 30 s POST_STIM both LEDs off
camera OFF
Running it
Path A — Python simulator (zero installs):
from cuewire.examples import TwoLedThermoSimulator, run_protocol
with TwoLedThermoSimulator() as sim:
run_protocol(sim.device_path, "two_led_thermo.log")
Path B — real firmware in simavr:
sudo apt install simavr libsimavr-dev
arduino-cli compile --fqbn arduino:avr:uno \
--output-dir /tmp/two_led_thermo_build \
examples/two_led_thermo/firmware/two_led_thermo
make -C examples/two_led_thermo/simavr
./examples/two_led_thermo/simavr/simrun \
/tmp/two_led_thermo_build/two_led_thermo.ino.hex &
python examples/two_led_thermo/run_protocol.py --port /tmp/simavr-uart0
See the full walkthrough in examples/two_led_thermo/README.md.