What you will learn
  • Upload a complete Arduino sketch.
  • Explain what setup() and loop() do.
  • Set a pin’s operating mode and output level.
  • Calculate an LED’s complete blink period.
  • Separate compilation, uploading and runtime faults.

Before you begin

Complete ARD01 and prepare an Uno R3, a data-capable USB cable and Arduino IDE. No external LED or resistor is needed for this lesson.

The first useful experiment

A blinking light may look small, but it verifies a complete chain: your editor, compiler, USB connection, board selection and a physical output. When you change the timing and see the change, you know the board is running your version of the program.

We use the Uno R3’s onboard LED, usually marked L. LED_BUILTIN is a named constant supplied by the board’s software package. On this reference board it refers to the onboard LED connection. Using the name communicates your intent more clearly than scattering a pin number through the sketch.

The board may already blink when it arrives. That is not your result yet. Our test deliberately changes the pattern so you can distinguish your uploaded sketch from an older one.

Parts, power and upload

Connect only the USB cable. The onboard LED already has the required board circuitry; do not add a resistor to an unrelated pin. Place the board on an insulating surface and leave the exposed headers clear.

Open a new sketch, replace its contents with the program below and save it as FirstBlink. Select Arduino Uno and its USB port. Verify compiles the program; Upload compiles and transfers it. Wait for the upload result before judging the LED. Arduino’s built-in examples provide another reference for this workflow.

PartConnection or purpose
Arduino Uno R3Onboard L LED is the output
Data-capable USB cableComputer USB to Uno USB connector
Arduino IDEEdit, verify and upload
External componentsNone for this project

The complete blink program

This is Arduino C/C++. The core functions are included by the Arduino environment, so no extra library installation is required. Copy the entire sketch, including braces and semicolons.

cpp
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(700);
  digitalWrite(LED_BUILTIN, LOW);
  delay(300);
}

setup() configures the LED connection as an output once. loop() sets that output HIGH, waits 700 milliseconds, sets it LOW and waits 300 milliseconds. A semicolon ends an instruction; braces group the instructions belonging to a function. delay() pauses the main sketch’s progress, although hardware and interrupts can still operate.

Expected result: The onboard L LED stays on for about 0.7 seconds and off for about 0.3 seconds, repeating once per second.

Read the timing correctly

A millisecond is one thousandth of a second. The full pattern contains both waiting periods, so its approximate period is 700 + 300 = 1,000 milliseconds. The time spent executing the other instructions is small here, but this is not a precision time reference.

The LED is on for 70% of each cycle. That fraction is called a duty cycle. This slow demonstration makes the fraction visible as time; much faster repeated switching is used later for dimming and motor control. delay(700) is not a brightness command.

digitalWrite() changes an output state. It does not report whether light actually appeared. Your eyes provide the measurement in this experiment. If you wanted automatic confirmation, you would need another sensor or circuit.

The program repeats because Arduino’s runtime calls loop() again after it finishes. You do not need to type another loop around it. A spelling change such as digitalwrite fails because names in C/C++ are case-sensitive.

Blocking delays are acceptable for this single-purpose lesson. They become inconvenient when a robot must check a stop button while doing something else. ARD09 replaces long waits with state and elapsed-time checks; learn the simple pattern here before adding that complexity.

Verify one change at a time

First compare the LED against a clock for several cycles. Then change only the first delay to 200 milliseconds and upload again. Now the expected period is 500 milliseconds, with 200 milliseconds on and 300 milliseconds off. Observing that exact change is stronger evidence than seeing any blink.

If compilation fails, read the first error and check punctuation near that location. If compilation succeeds but uploading fails, inspect the selected board, port and data cable. If uploading succeeds but the pattern seems unchanged, confirm you watched the L LED rather than the power LED and uploaded the saved sketch you intended.

Reset should restart the same program. Disconnecting and reconnecting USB should also run the stored sketch. You do not need the IDE to remain open after upload, though this experiment continues to obtain its power from USB.

Do not extend this circuit to an external LED until ARD03 explains current limiting. The onboard LED’s protection does not automatically protect a separate component plugged into the headers. The finish condition is a repeatable, intentionally changed onboard pattern.

Important terms

Function
A named group of instructions.
OUTPUT
A mode in which a pin drives an electrical signal.
HIGH and LOW
Named digital output levels, not promises of unlimited current.
Millisecond
One thousandth of a second.
Period
Time required for one complete repeating cycle.
Duty cycle
The fraction of a cycle during which an output is active.

Mini project: Prove that your new sketch is running

  1. Upload the 700/300 sketch and observe at least five cycles.
  2. Write its predicted period before timing it.
  3. Change the on-time to 200 milliseconds and upload again.
  4. Record the new expected and observed periods.
  5. Press reset and confirm that the new pattern returns. Finish when the two intentionally different patterns both match your predictions.

Common mistakes and debugging

  • Watching the power LED: use the LED labelled L; the power indicator is not controlled by this sketch.
  • Changing code without uploading: edits on the computer do not change the program already stored on the board.
  • Counting only one delay: the full period includes both on-time and off-time.
  • Removing a semicolon while changing a number: correct the first compiler error before chasing later messages.

Independent challenge

Create a pattern with a short flash followed by a long flash, then a longer pause. Calculate the total period from every delay and verify it experimentally.

Check your understanding: 10 questions

  1. How often does setup() run?

  2. What does pinMode(LED_BUILTIN, OUTPUT) establish?

  3. What is the period of 200 milliseconds on and 300 milliseconds off?

  4. Does editing a delay immediately change the board?

  5. Why will long delay() calls become a problem for a robot?

  6. In your own words, what does “Function” mean?

  7. In your own words, what does “OUTPUT” mean?

  8. In your own words, what does “HIGH and LOW” mean?

  9. In your own words, what does “Millisecond” mean?

  10. In your own words, what does “Period” mean?

Quiz answers

Reveal all 10 answers after your attempt
  1. Once each time the board starts or resets.
  2. That the selected connection should drive an output signal.
  3. 500 milliseconds, or half a second.
  4. No. You must upload the changed sketch.
  5. They prevent the main sketch from promptly checking other inputs and making decisions.
  6. A named group of instructions.
  7. A mode in which a pin drives an electrical signal.
  8. Named digital output levels, not promises of unlimited current.
  9. One thousandth of a second.
  10. Time required for one complete repeating cycle.

Summary

Blink verifies the path from source code to a physical result. You can now configure an output, change its state and predict a repeating pattern.

Continue learning

ARD03 explains why an external LED needs a resistor and how breadboard connections form a safe circuit.

Choose a connected learning path

Sources and further reading

Prepared 2026-09-18. Editorial draft; primary documentation consulted. Hardware build not bench-tested; code has not been executed on the reference board.

GO DEEPER

Extra reading & source documents

Optional reading alongside the lessons. These sources do not add to your course lesson count.

Explore the AI model guides →