Built-in project · SparkFun Pro Micro

Pro Micro blink

A board with no LED on pin 13 blinks its RX lamp instead, with an LED on pin 9 beside it wired the ordinary way around. The whole build, a SparkFun Pro Micro and 2 more parts, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Beginner About 10 minutes to build and run. Runs in your browser. Free, and no account needed.

The parts retail for about $15.15. On Mokxi they're free.

The circuit runs here once the page has loaded.

What you'll learn

  • LEDs that light on LOW versus on HIGH
  • Boards with no pin 13 LED
  • Built-in lamp macros like RXLED1
  • Wiring an LED with a resistor to a pin
  • Difficulty: Beginner
  • Time: About 10 minutes
  • Board: SparkFun Pro Micro
  • Parts: 4

How it works

The SparkFun Pro Micro does not bring pin 13 out, so LED_BUILTIN would light nothing you can see. Instead every ATmega32U4 board has an RX and a TX lamp, each wired from 5 V through a resistor to a pin. The pin has to go LOW to light one.

The sketch blinks the RX lamp, and at the same time blinks an LED you wire from pin 9 through a 220 ohm resistor to ground. That LED lights the ordinary way, on HIGH. Each state lasts half a second, so you can see both kinds of LED side by side.

Parts list

4 parts, plus the jumper wires. They retail for about $15.15; on Mokxi they're free.

Wiring table

Every connection, pin by pin, read from the circuit itself. Each row joins the pin on the left to the pin on the right, by a jumper wire or a breadboard strip.

Part and pinConnects to
LED, red pin CSparkFun Pro Micro pin GND
Resistor, 220 Ω pin 2SparkFun Pro Micro pin 9
LED, red pin AResistor, 220 Ω pin 1

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · SparkFun Pro Micro
// RX blink: the lamp a board with no pin 13 still has.
//
// Every ATmega32U4 board has an RX and a TX LED, and both are wired from 5 V
// through a resistor to a pin: RX to PB0, TX to PD5. So the pin has to go LOW
// to light one. RXLED1 does that and RXLED0 lets it go dark again.
//
// On a Leonardo or a Micro this blinks the RX lamp beside L. On a SparkFun Pro
// Micro, which does not bring pin 13 out at all, it is the only way to see a
// blink without wiring anything: LED_BUILTIN is still 13 there, and blinking
// it lights nothing.
//
// Pin 9 blinks at the same time the ordinary way round, HIGH for on, so an
// LED and a resistor from pin 9 to GND show the difference side by side.

const int WIRED = 9;

void setup() {
  TX_RX_LED_INIT;
  TXLED0;
  pinMode(WIRED, OUTPUT);
}

void loop() {
  RXLED1;                     // lamp on: PB0 low
  digitalWrite(WIRED, HIGH);  // wired LED on: pin 9 high
  delay(500);
  RXLED0;                     // lamp off: PB0 high
  digitalWrite(WIRED, LOW);
  delay(500);
}

Code walkthrough

The key functions of the sketch, and what each one does.

setup sketch.ino

TX_RX_LED_INIT prepares the RX and TX lamp pins as outputs, and TXLED0 lets the TX lamp go dark. Then pinMode makes the WIRED pin (9) an output.

void setup() {
  TX_RX_LED_INIT;
  TXLED0;
  pinMode(WIRED, OUTPUT);
}

loop sketch.ino

RXLED1 pulls the RX pin low, so the lamp lights, and pin 9 goes HIGH to light your LED. After 500 ms, RXLED0 lets the lamp go dark and pin 9 goes LOW. Then it waits another 500 ms.

void loop() {
  RXLED1;                     // lamp on: PB0 low
  digitalWrite(WIRED, HIGH);  // wired LED on: pin 9 high
  delay(500);
  RXLED0;                     // lamp off: PB0 high
  digitalWrite(WIRED, LOW);
  delay(500);
}

Troubleshooting

The usual mistakes with this circuit, and the fix for each.

  • Nothing blinks on the board This project
    Blinking LED_BUILTIN lights nothing here. The sketch uses RXLED1 and RXLED0 for the lamp that exists.
  • Your LED never lights This project
    Check its direction: the cathode goes to GND, and the resistor connects pin 9 to the anode.
  • The LED is dim, burns out, or the pin reads wrong because the resistor value is off. Resistor
    Read the color bands again. A 220 ohm to 330 ohm resistor suits a typical LED on 5 V. 10k is a common pull-up or pull-down value. Check with a multimeter if unsure.
  • A pull-up or pull-down resistor is missing, so the input floats and reads random values. Resistor
    Tie the input to 5 V or ground through about 10k. Or use INPUT_PULLUP and wire the switch to ground.
  • The LED does not light, or it lights once and then dies. LED
    LEDs have polarity. The longer leg (anode) goes toward the positive side. Always add a series resistor, about 220 ohms to 1 k ohm on a 5 V pin.
  • A blue or white LED stays dark on 3.3 V. LED
    Blue and white LEDs drop about 3 V, so 3.3 V leaves almost nothing for the resistor. Use a 5 V supply, or a smaller resistor and a red or green LED.
  • The upload fails or the wrong board is selected. SparkFun Pro Micro
    Pick SparkFun Pro Micro and match the 5 V 16 MHz or 3.3 V 8 MHz version printed on your board. A wrong choice can make the board hard to program.
  • Serial output seems missing, or the sketch hangs at start. SparkFun Pro Micro
    Serial is on the native USB port, so use while(!Serial) only when you want to wait for a monitor. For Serial1 use pins TX and RX. Pin numbers differ from an Uno, so check the pinout.

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.