1. Arduino Uno vs. ESP32 vs. BBC Micro:bit: Which Board Fits Your Project?
Each microcontroller excels at a different stage of a student’s robotics journey:
| Feature | BBC Micro:bit v2 | Arduino Uno (R3 / R4 WiFi) | ESP32 DevKit |
|---|---|---|---|
| Best Age / Grade | Ages 9–13 (Grades 5–6) | Ages 11–16 (Grades 6–9) | Ages 13–18 (Grades 7–12 & IoT clubs) |
| Main Language | MakeCode Blocks & MicroPython | Arduino C++ (standard curriculum) | Arduino C++ / MicroPython |
| GPIO Logic Voltage | 3.3V | 5V (very forgiving for beginners) | 3.3V strict (5V damages pins!) |
| Wi-Fi & Bluetooth | Bluetooth built-in | None on R3 (Wi-Fi on R4 WiFi) | Dual-mode Wi-Fi + BLE built-in |
| Key Advantage | Built-in 25-LED matrix, buttons, mic & compass | Massive ecosystem & 5V sensor compatibility | 240 MHz dual-core CPU, huge RAM, cheap Wi-Fi IoT |
2. How PWM (analogWrite) and I2C (SDA/SCL) Actually Work
Digital pins only output 0V or 5V/3.3V. To dim an LED or vary motor speed smoothly, Pulse Width Modulation (PWM) switches the pin hundreds of times per second using analogWrite(pin, 0..255), controlling the Duty Cycle percentage.
To connect OLED/LCD screens or multiple sensors over just TWO data wires instead of ten, microcontrollers use the I2C bus: SDA (Data) and SCL (Clock), where each device listens on its own hex address (e.g., 0x27 or 0x3C).
| analogWrite Value | Duty Cycle | Equivalent Avg Voltage | LED / Motor Behavior |
|---|---|---|---|
| 0 | 0% | 0.0 V | Completely off |
| 64 | 25% | 1.25 V | Dim glow / low power |
| 127 | 50% | 2.50 V | Half brightness / medium speed |
| 255 | 100% | 5.00 V | Full continuous HIGH |
3. Full C++ Sketch: Adaptive Smart Streetlight (LDR + PWM + millis())
This sketch reads an analog LDR photoresistor (A0), maps darkness smoothly onto PWM pin ~9, and schedules checks without blocking via millis():
const int PIN_LDR = A0;
const int PIN_LED_PWM = 9; // Must be a ~ PWM-capable pin
unsigned long lastCheck = 0;
void setup() {
pinMode(PIN_LED_PWM, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (millis() - lastCheck >= 200) {
lastCheck = millis();
int lightLevel = analogRead(PIN_LDR); // 0 (dark) .. 1023 (bright)
int pwmPower = constrain(map(lightLevel, 0, 1023, 255, 0), 0, 255);
analogWrite(PIN_LED_PWM, pwmPower);
}
}
4. Top 7 Breadboard Mistakes That Burn LEDs, Sensors, or Boards
Before plugging in your USB cable, run through these 7 lab safety checks:
- Wiring an LED without a 220 Ω–330 Ω series resistor → overcurrent instantly burns the LED or pin.
- Feeding a 5V signal (e.g., HC-SR04 ECHO) directly into a 3.3V ESP32 GPIO → always add a resistor voltage divider.
- Powering heavy servos or DC motors directly from Arduino’s 5V pin → use an external supply + driver (L298N).
- Forgetting a shared Common Ground (GND) between external motor batteries and the microcontroller.
- Reversing polarized components (electrolytic capacitors) or LED legs.
- Leaving bare bent leads touching across power rails (+ / − short circuit).
- Attaching sensors to pins 0 & 1 (RX/TX) on Arduino Uno, which blocks USB sketch uploads.
If the board feels hot or smells slightly burnt, unplug USB IMMEDIATELY and double-check 5V/GND rails before reconnecting!