ROBOTICS · LEVEL 1 · ARDUINO FOUNDATIONS · LESSON 02

Build a Push-to-Shine Arduino Light

Turn a finger press into light—and learn why a button needs a clear electrical answer.

Last time, you told an Arduino to blink its own light. Today, you will build your first breadboard circuit and give the Arduino a new skill: it will notice your finger pressing a button and turn on a light you wired yourself.

This is a small version of something real engineers do constantly: turn an input—such as a button, sensor, or switch—into an output. By the end, you will make the first version work, explain why it works, and add a second light with the opposite rule.

At a glance

Age range10–13
Estimated time60–75 minutes
DifficultyBeginner—first breadboard circuit
Parent involvementMedium at the start; light during building and debugging
Major conceptsBreadboard connections, LED polarity, button input, INPUT_PULLUP, if/else, digital inputs and outputs

What you will learn

  • How a breadboard connects holes together without soldering.
  • How to wire an LED safely with a resistor.
  • How to use a button as a digital input.
  • Why a button wired with INPUT_PULLUP reads LOW when pressed.
  • How an if/else statement lets an Arduino choose between two actions.
  • How to make and test a change instead of merely copying a circuit.

Before you begin

Complete Lesson 1: Build Your First Arduino Blinking Beacon first. Your Uno should still appear in Arduino IDE as Arduino Uno with the correct port selected. If it does not, remove all wires and run the built-in Blink test from the course introduction before building a circuit.

For the first 10 minutes, you may rehearse this circuit in Tinkercad Circuits. This is optional but useful for seeing which breadboard holes connect. It is not a replacement for the real build: use the physical Arduino and parts for the lesson itself.

Keep the Debugging Ladder nearby. This lesson introduces two new physical ideas—breadboard rows and component direction—so we will test them one at a time.

What you need

Required components

QuantityItemCompatible substitute
1Arduino Uno from the Arduino Student KitGenuine Uno R3 or Uno R3 SMD
1Solderless breadboardAny standard half-size breadboard
1LED, any colorAny ordinary 3–5 mm LED
1220 Ω resistor330 Ω or 560 Ω resistor; do not omit it
1Four-leg tactile pushbuttonMomentary tactile button that fits the breadboard
5–7Male-to-male jumper wiresSolid-core breadboard wires
1USB-A to USB-B data cableArduino-branded USB-A-to-B data cable

Optional components

  • A second LED and a second 220 Ω resistor for the required change-it challenge.
  • A maker notebook and pencil.
  • Small labels or masking tape to mark D2, D9, and ground wires.

Tools

None. This project is solderless.

Computer/software requirements

  • Arduino IDE 2, with Arduino Uno and its port selected.
  • A Mac running macOS 10.15 or later, or Windows 10 64-bit or newer.
  • Optional: a free Autodesk account and current Chrome, Safari, or Chromium Edge for Tinkercad.

Safety and setup notes

  • Unplug the USB cable before moving wires. Plug it back in only when the circuit is ready for a test.
  • Use the resistor with the LED every time. A resistor slows the electricity down enough to protect the LED and the Arduino pin.
  • Use only USB power today. Do not connect the 9 V battery, wall power, or any unknown electronics.
  • A button has no positive or negative side. An LED does: its long leg is the positive side (anode); its short leg and flat edge mark the negative side (cathode).
  • The adult helps only with the first look at the breadboard and with a circuit that becomes warm. The student places wires, traces connections, uploads code, predicts behavior, and records tests.

Build overview

This project has one input and one output:

Finger presses button → Arduino reads D2 → code makes a decision → LED on D9 turns on

The button does not need an extra resistor because the Uno can turn on an internal pull-up resistor in software. With INPUT_PULLUP, the button pin normally reads HIGH. When you press the button, you connect that pin to ground, so it reads LOW.

That sounds backward at first: pressed = LOW. It is not a mistake. It is simply the rule for this particular, simpler wiring plan.

Step-by-step build instructions

Step 1: Learn the two important breadboard patterns

Place the breadboard so the long center trench runs left to right.

  • In the main area, each short group of five holes on one side of the trench is connected. Holes do not connect across the center trench.
  • The long edge rails are convenient ground/power highways. For this project, use one rail only as your ground rail.

Put a short black jumper from an Arduino GND pin to the breadboard ground rail.

Checkpoint: point to the Uno’s GND pin, follow the black wire, and point to the ground rail. Do not connect the button or LED yet.

Step 2: Wire the LED output

  1. Place the LED in the main breadboard area. Its two legs must be in different connected rows.
  2. Find the LED’s short leg or flat side. Use a black jumper to connect that row to the breadboard ground rail.
  3. Put one end of the 220 Ω resistor in the row with the LED’s long leg. Put the other end in a different, empty row.
  4. Run a colored jumper from Arduino digital pin D9 to the resistor’s free end.
FromToWhy
Arduino GNDBreadboard ground railGives the circuit a path back to the Arduino
LED short leg / flat side rowGround railCompletes the LED circuit
LED long leg rowOne end of 220 Ω resistorSends current safely toward the LED
Other end of 220 Ω resistorArduino D9Lets code control the light

Checkpoint: the LED, resistor, and D9 jumper make one continuous path; the LED’s short leg goes to ground. Ask before plugging in: Which part protects the LED?

Step 3: Wire the button input

  1. Place the tactile button so it straddles the long center trench. One pair of its legs should be on one side of the trench and the other pair on the other side. Do not put all four legs in one connected group of holes.
  2. Connect a jumper from one side of the button to Arduino digital pin D2.
  3. Connect a jumper from the opposite side of the button to the breadboard ground rail.
  4. Do not connect this button to 5 V. The internal pull-up resistor in the code will handle the normal, unpressed state.

Checkpoint: trace only the button circuit: D2 → one button side → other button side → ground. When the button is released, the two sides are not connected. When pressed, they touch electrically.

Step 4: Upload the first working program

  1. Connect the Uno to the computer with the USB cable.
  2. Open Arduino IDE and confirm Arduino Uno and its port are selected.
  3. Create a new sketch, remove any starter code, and paste or type the code in the next section.
  4. Click Verify (the checkmark). Fix a code error before uploading.
  5. Click Upload and wait for Done uploading.

Checkpoint: press and hold the button. The LED should shine only while you are pressing it. Release the button and it should turn off.

Step 5: Test the input before changing anything

Make this prediction: What value does the Arduino read when the button is pressed: HIGH or LOW? Why?

Then press/release the button five times. Does the LED follow every press? If not, do not change the code yet. Use the project debugging guide and test one physical connection at a time.

Code

const int BUTTON_PIN = 2;
const int ACTIVE_LED_PIN = 9;

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(ACTIVE_LED_PIN, OUTPUT);
}

void loop() {
  bool buttonPressed = digitalRead(BUTTON_PIN) == LOW;

  if (buttonPressed) {
    digitalWrite(ACTIVE_LED_PIN, HIGH);
  } else {
    digitalWrite(ACTIVE_LED_PIN, LOW);
  }
}

What the important code means

  • Variables: BUTTON_PIN and ACTIVE_LED_PIN give clear names to the real pin numbers. buttonPressed is a variable that can be either true or false.
  • setup(): this runs once. It tells the Arduino that D2 will be an input with an internal pull-up resistor and D9 will be an output.
  • loop(): this runs over and over, so the Arduino checks the button thousands of times each second.
  • Inputs and outputs: digitalRead(BUTTON_PIN) reads the button input. digitalWrite(ACTIVE_LED_PIN, ...) controls the LED output.
  • The new condition: if (buttonPressed) asks a yes/no question. If the answer is yes, the LED turns on. else means “otherwise,” so it turns the LED off.
  • Why == LOW? The double equals sign asks, “is this equal to?” Because INPUT_PULLUP makes the pin normally HIGH, a pressed button connects it to ground and reads LOW.

Make it work

The first version works when all of these are true:

  1. Arduino IDE says Done uploading.
  2. The LED is off when the button is released.
  3. The LED turns on immediately while the button is pressed.
  4. You can point to the resistor and explain that it protects the LED.
  5. You can point to D2 as the input and D9 as the output.

Understand it

  1. Why is the LED’s long leg connected toward D9 and its short leg connected to ground?
  2. What job does the 220 Ω resistor do?
  3. Why does the code use INPUT_PULLUP instead of ordinary INPUT?
  4. Predict what would happen if you changed == LOW to == HIGH but changed nothing in the wiring.
  5. What does the Arduino do over and over inside loop()?

Required “change it” challenge

Desired outcome: add a second LED on D10 that turns on when the button is not pressed. The original LED on D9 should turn on only when the button is pressed. You are building a two-light “go/stop” signal.

Constraints: use a second LED and its own 220 Ω resistor; do not add another button; use a clear new pin name; only one LED should be on at a time.

Hints:

  1. Draw a two-row truth table: button pressed / button released. Decide which light belongs in each row.
  2. Wire the second LED exactly like the first LED, but use D10 instead of D9. Never make two LEDs share one resistor.
  3. Add one new constant, one pinMode line, and one digitalWrite line inside each branch of the if/else. In each branch, the two LEDs must get opposite instructions.

Parent guidance: let the student draw the two rows and attempt the new wiring/code on his own. Seven to twelve minutes of trying is appropriate. If he gets stuck, ask, “When the first LED is HIGH, what must the second one be?” Step in if he omits the second resistor, puts the LED in backwards after checking the diagram, or has completed a careful one-wire trace without a next test.

Optional enhancements

Try this

Choose colors and make a cardboard label for the two-light signal. Write what each color means, then ask another person to predict the rule before pressing the button.

Challenge

Change the code so the pressed LED blinks while you hold the button instead of staying steadily on. Start by adding a short delay() in the pressed part of the if statement and predict the result. Notice whether the button still feels responsive.

Stretch

Build a small cardboard control panel with a “mission button,” two labeled lights, and a pretend use for it: a robot-start signal, a quiet-game buzzer, a model elevator, or a safe/unsafe indicator. Draw the input → decision → output path on the back.

Debugging guide

What you noticeLikely causeSmallest next diagnostic step
The board is not detected or the green power LED is offCable/port problem, not the circuitRemove all circuit wires and run the Lesson 1 built-in Blink test with the supplied data cable.
The LED never lightsLED is reversed, D9/resistor path is open, or ground is missingCheck only the LED path: D9 → resistor → long LED leg → short LED leg → ground. Reverse the LED only if that path is correct.
The LED is always onButton wire is on the wrong button side, button does not cross the trench, or code treats released as pressedRemove the D2 wire and confirm the LED turns off; then check the button placement and == LOW.
The LED never responds to the buttonD2 wire is loose/wrong, button legs sit in the same connected breadboard section, or ground is not sharedTrace D2 → button → ground. Move the button so it crosses the center trench.
Pressing the button makes the LED turn offThe input logic is reversedPredict what changing == LOW to == HIGH will do, then test that one code change.
The LED is very dim or gets warmWrong resistor value, shorted wiring, or no resistorUnplug immediately. Verify there is one 220 Ω/330 Ω/560 Ω resistor in series with the LED and no direct D9-to-ground path.
Arduino IDE shows a code errorMisspelled INPUT_PULLUP, missing semicolon, or unmatched braceRead the first error, then compare only that line and the line above it to the complete sketch.
The original circuit works but the two-light challenge does notThe second LED is wired to a different pin than the code, or both LEDs receive the same instructionTest the second LED alone with a temporary digitalWrite(D10, HIGH) line; then compare both if/else branches to the truth table.

Use the Debugging Ladder if one small diagnostic does not reveal the problem. Do not rebuild the entire circuit unless you have traced it and found multiple uncertain connections.

Recap

You built your first external Arduino circuit. The button became an input, the LED became an output, and an if/else statement connected the two with a rule. You also learned a useful real-world pattern: INPUT_PULLUP makes the wiring simpler, but it means a pressed button reads LOW.

Show what you learned

Write or tell your parent:

  • What did you change in the required two-light signal?
  • What failed, if anything, and which debugging rung did you test?
  • What would you improve about your control panel next time?
  • Explain, in your own words, why the code says digitalRead(BUTTON_PIN) == LOW.

In your notebook, draw the two possible button states and label which LED should be on in each one. Take a photo of the final breadboard from directly above.

What’s next

Next, you will direct a mini traffic signal with three LEDs. The LED-and-resistor pattern you built today will appear three times, and you will start organizing longer code with small functions.

NEXT · LESSON 03

Lesson 3: Program a Mini Traffic Signal

Parent guide

Prepare in advance

  • Complete the Lesson 1 upload check. Confirm Arduino IDE still sees the Uno and its port.
  • Put out only the Uno, breadboard, one LED, one 220 Ω resistor, one button, jumpers, and notebook. Keep the second LED/resistor aside until the required challenge.
  • Keep the visual breadboard layout open on a second screen or printed beside the work area.
  • Decide in advance that a direct overhead photo will be the first debugging step if a wire trace becomes confusing.

Let the child work independently when

  • placing the LED and resistor after identifying the long/short LED legs;
  • tracing one wire from an Arduino pin to the part it controls;
  • typing/uploading the first sketch and making predictions; and
  • creating the two-row truth table for the required change.

Resist taking over when

  • he puts a wire in the wrong row but can compare it calmly with the diagram;
  • the LED is reversed and he can identify the flat side/short leg himself;
  • he is working out which opposite instruction belongs in an if/else branch; or
  • his cardboard panel is imperfect but communicates the idea.

Step in when

  • a resistor has been omitted, a component gets warm, or a wire may be making a direct short;
  • the computer/board connection fails before any circuit test can begin;
  • frustration continues after one careful wire trace and one small diagnostic; or
  • roughly 20 minutes pass with no new hypothesis. Restore the known-good Lesson 1 Blink sketch if needed, then rebuild one subsystem—LED first, button second.

Simple understanding-based assessment

Ask the student to point to: (1) the input, (2) the output, (3) the resistor, and (4) the code line that makes a decision. Then ask, “Why is pressed LOW in this circuit?” Award one point each for a working/tested build, a correct explanation, a deliberate two-light change, and a useful debugging/notebook note. A working light without the explanation is not a complete success.

Further resource: Arduino: Getting Started with Arduino