Built-in project · Arduino Uno R3

Starship control panel on an Arduino Uno

A green lamp waits and two red lamps flash in turn while you hold the button, read through a 10k pull-down on pin 2. The whole build, an Arduino Uno and 8 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 Runs in your browser. Free, and no account needed.

Build it as the Starter Projects Kit: the parts in numbered bags and a booklet that checks every step. Free.

Starship control panel · Arduino Uno R3live0.000 s 0.00x
Hold the button
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

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

sketch.ino · Arduino Uno R3
// Starship control panel: a green "ready" lamp, and two red lamps that flash
// in turn while the launch button is held.
//
//   pin 2   the button: one leg to 5V, the other to pin 2 and through a 10k
//           resistor to GND (a pull-down)
//   pin 3   the green LED, through 220 ohm to GND
//   pin 4   the first red LED, through 220 ohm to GND
//   pin 5   the second red LED, through 220 ohm to GND
//
// The 10k resistor holds pin 2 at 0 V while the button is up, so it reads LOW
// rather than floating. Press the button and it joins pin 2 to 5 V: HIGH.
// This is the opposite of INPUT_PULLUP, where pressed reads LOW.

const int BUTTON = 2;
const int GREEN = 3;
const int RED_A = 4;
const int RED_B = 5;

int lastButton = LOW;

void setup() {
  pinMode(BUTTON, INPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(RED_A, OUTPUT);
  pinMode(RED_B, OUTPUT);
  Serial.begin(9600);
  Serial.println("Mokxi Uno: starship control panel");
}

void loop() {
  int button = digitalRead(BUTTON);
  if (button != lastButton) {
    lastButton = button;
    Serial.println(button == HIGH ? "launch!" : "ready");
  }

  if (button == LOW) {
    // Waiting: green on, both reds off.
    digitalWrite(GREEN, HIGH);
    digitalWrite(RED_A, LOW);
    digitalWrite(RED_B, LOW);
  } else {
    // Held: green off, the reds take turns every quarter second.
    digitalWrite(GREEN, LOW);
    digitalWrite(RED_A, HIGH);
    digitalWrite(RED_B, LOW);
    delay(250);
    digitalWrite(RED_A, LOW);
    digitalWrite(RED_B, HIGH);
    delay(250);
  }
}

Parts list

10 parts, plus the jumper wires. Every one is in the editor's parts bin.

How it is wired

10 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Ground: Arduino Uno R3 pin GND; Resistor, 10k Ω pin 1; LED, green pin C; LED, red (1) pin C; LED, red (2) pin C
  • Arduino Uno R3 pin 5; Resistor, 220 Ω (3) pin 1
  • Arduino Uno R3 pin 4; Resistor, 220 Ω (2) pin 1
  • Arduino Uno R3 pin 3; Resistor, 220 Ω (1) pin 1
  • Arduino Uno R3 pin 2; Pushbutton pin 2a
  • Arduino Uno R3 pin 5V; Pushbutton pin 1a
  • Pushbutton pin 2b; Resistor, 10k Ω pin 2
  • Resistor, 220 Ω (1) pin 2; LED, green pin A
  • Resistor, 220 Ω (2) pin 2; LED, red (1) pin A
  • Resistor, 220 Ω (3) pin 2; LED, red (2) pin A

Change it and keep it

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