Digital ChallengeWorkshop · Arduino × Processing
Reference

The pocket dossier.

Serial contracts, pin numbers, vocabulary and the corrections we made to the original workshop file. Project 2024-2-RS01-KA210-SCH-000271542.

Serial contracts

One line, newline at the end, 9600 baud. Close the Serial Monitor before Processing starts.

LabArduino printsProcessing expects
L01 Climate24.50,61.00two floats, comma
L02 Light731one integer 0–1023
L03 Distance50.12one float (cm)
L03 Radar90,42.0angle,distance
L03 Combodistance: 42.0 cmparse the number out
L04 Ohm1500.0 or -1ohms, or OPEN
L05 Soil610one integer, calibrate yourself

Default pin map

LabSignals
L01 DHT11DATA → D2 · 10 kΩ pull-up on a bare sensor
L02 LDRjunction → A0 · LDR to 5V · 10 kΩ to GND
L03 DistanceTRIG D3 · ECHO D2
L03 Servosignal D9 · red 5V · brown GND
L03 ComboTRIG D6 · ECHO D7 · servo D9
L03 Radarservo D6 · TRIG D9 · ECHO D10
L04 Ohmjunction → A0
L05 SoilAOUT → A0

Glossary

ADC
Analog-to-digital converter. 5 V / 1023 ≈ 4.9 mV per step.
L02
analogRead()
Arduino function that samples A0–A5 as an integer 0–1023 (10-bit ADC, 0–5 V).
L02
Blocking code
A `for` + `delay` that hogs `loop()` so serial commands (STOP) are ignored until the sweep ends.
L03
Calibration
Recording real readings in known states (dry cup, damp cup, wet cup) so 0–1023 becomes a meaning.
L05
Capacitive probe
Measures soil as a dielectric. The electronics stay out of the water, so it lasts longer.
L05
CSV
Comma-separated values. One line, two numbers: `24.5,61`.
L01
DHT11
A low-cost digital sensor for temperature (0–50 °C, ±2 °C) and relative humidity (20–90 % RH, ±5 %).
L01
HC-SR04
Ultrasonic ranger. TRIG sends a 40 kHz burst; ECHO stays HIGH for the round-trip time.
L03
Hysteresis
Two thresholds — on and off — so a pump does not chatter at one magic number.
L05
Known / reference resistor
The resistor whose value you trust (here 1 kΩ). You calculate the other one from it.
L04
LDR / photoresistor
A resistor whose resistance drops when more light hits it.
L02
Library
Ready-made code you include so you do not have to speak the sensor’s protocol yourself.
L01
map()
Processing (and Arduino) helper that remaps a number from one range into another.
L02
NaN
“Not a Number” — what `dht.readTemperature()` returns when the read failed. Test with `isnan()`.
L01
Ohm’s law
V = I × R. Voltage, current and resistance are three faces of one relationship.
L04
Open circuit
No path for current. `analogRead` sits near 0 or 1023 and the formula explodes — guard it.
L04
Polar coordinates
A point as (distance, angle). Radar screens are polar plots.
L03
Pull-up resistor
A resistor that keeps a signal line HIGH when nothing is pulling it LOW. Needed on a bare 3-pin DHT11.
L01
pulseIn()
Waits for a pin to go HIGH (or LOW) and returns the duration in microseconds. Always pass a timeout.
L03
Relative humidity (RH)
How much water vapour the air holds compared with the maximum it could hold at that temperature, in %.
L01
Resistive probe
Two exposed legs. Current flows through damp soil. Cheap, rusts, the handbook figure looks like this.
L05
serialEvent()
A Processing function that runs when a full serial line arrives. Safer than reading inside `draw()`.
L01
SG90
Hobby servo. `Servo.write(0…180)` asks for an angle. It needs 5 V and its own GND.
L03
Speed of sound
About 343 m/s in dry air at 20 °C. It rises ~0.6 m/s per °C.
L03
Tolerance
A 1 kΩ ±5 % resistor may actually be 950–1050 Ω. That error transfers into R_x.
L04
Voltage divider
Two resistors in series. The middle tap is a fraction of the supply voltage.
L02

Teacher notes & errata

The original .docx repeated every sketch twice, used HTML entities in Processing, and contradicted itself on the ohm-meter formula. This edition keeps the same five labs and the same photos, and writes one clean copy of each program.

Lab 01 · Wiring figure

The original Tinkercad figure shows the DHT11 floating above the board — DATA is not drawn to pin 2.

Follow the pin table: VCC→5V, GND→GND, DATA→D2. Use a 10 kΩ pull-up on a bare 3-pin sensor.

Lab 01 · Processing

The original sketch used HTML entities (`'`) and read serial inside `draw()`.

Use a real newline character and `serialEvent()` with `bufferUntil('\n')`.

Lab 03 · Servo sweep

Blocking `for` loops meant STOP was ignored until a full 0–180–0 sweep finished.

One `servo.write()` per `loop()`, check serial every step.

Lab 03 · pulseIn

`pulseIn()` with no timeout can freeze for about 1 s when there is no echo.

Always pass a timeout, e.g. `pulseIn(echoPin, HIGH, 30000)`.

Lab 04 · Formula

The handbook text used two opposite Ohm-meter formulas. The diagram labels unknown on the 5 V side.

R_x = R_known × (V_in / V_A0 − 1). Code, wiring table and figure now match.

Lab 05 · Sensor type

The text says “capacitive v1.2”; the figure shows a two-prong resistive probe.

Either sensor works on A0. Capacitive probes last longer in wet soil; resistive probes rust. Calibrate dry / damp / wet for *your* probe.

Safety
  • USB only for the Uno + one SG90. If the board resets, give the servo its own 5 V and a common GND.
  • No mains. No 12 V pumps in this workshop edition.
  • Dry resistive soil probes after the lesson.
  • One COM port owner at a time — Serial Monitor or Processing, never both.