Your first Arduino program: from installing the IDE to a blinking LED
Install the Arduino IDE, pick the board and port, understand setup and loop, write and improve the blink program, and fix common upload errors.
- 8 min read
In programming, the first program a learner writes usually prints “Hello, world” on the screen. In electronics, the first program makes a small light blink: on for a second, off for a second, over and over. It may sound simple, but it teaches you every basic you will build much bigger projects on: installing the programming environment, choosing the board and port, the structure of any Arduino program, code controlling the physical world, and uploading the program to the board. In this article we take you step by step from a computer that knows nothing about Arduino to an LED blinking at a rhythm you choose, then develop the program into traffic lights and a push button, and solve the problems beginners most often meet.
What you will learn
- Installing the Arduino IDE and setting up the board and port.
- The structure of any Arduino program: the setup and loop functions.
- Writing the blink program and understanding every line of it.
- Extending the program with an external LED and a button, and fixing common upload problems.
Step 1: install the programming environment
Go to the official site, arduino.cc, and download the latest Arduino IDE for your operating system; it is free. Install it like any other program, and accept the driver installation if asked – drivers are what let the computer recognise the board. There is also a version that runs in the browser, but the installed version suits beginners better because it does not need a constant internet connection.
Step 2: connect the board and choose the port
Connect the Uno to the computer with a USB cable. The power light on the board will come on. In the IDE, choose Arduino Uno from the boards list, then choose the port that appeared when you connected the board. On Windows it is usually called COM followed by a number; on macOS and Linux it usually starts with /dev. If you are not sure which port it is, unplug the board, note which port disappears from the list, then plug it back in.
Step 3: understand the program’s structure
A program in the Arduino world is called a sketch, and it is written in a language based on C and C++, with a library that makes working with pins easy. Every program contains two essential functions:
setup(): runs once when the board powers up or the reset button is pressed. We put settings here, such as deciding what each pin does.loop(): runs over and over without stopping for as long as the board is on. We put here whatever we want to keep happening.
Step 4: write the blink program
// Blink: the built-in LED on for one second, off for one second
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
Every line explained
- The first line is a comment starting with two slashes. Comments are for people; the computer ignores them. Get into the habit of writing comments that explain the purpose of your code.
pinMode(LED_BUILTIN, OUTPUT)tells the board that the pin connected to the built-in LED will be an output – we will send a signal from it.LED_BUILTINis a ready-made name for pin 13 on the Uno.digitalWrite(LED_BUILTIN, HIGH)sends a high voltage (5 volts) to the pin, and the LED lights up.delay(1000)pauses the program for 1000 milliseconds – one second.digitalWrite(..., LOW)cuts the voltage and the LED goes off. Then we wait another second, and loop starts again.
Notice that every statement ends with a semicolon, and that curly braces mark the start and end of a function. A forgotten semicolon is one of the most common beginner mistakes.
Step 5: verify and upload
Press the Verify button (the tick) to compile the program and check it for errors. If an error message appears, read it calmly; it usually points to a line number. Then press the Upload button (the arrow). Small lights on the board will flicker while the program transfers, then the built-in LED starts blinking. Congratulations: you have programmed a physical device!
In the following video Paul McWhorter explains setting up and programming the Arduino for absolute beginners; it is the first lesson in a long, graded series:
Develop the program
Try different rhythms
Change the delay numbers: 200 and 200 give a fast blink, and 100 then 900 give a short flash once a second. Experimenting and changing things is the fastest route to understanding.
An external LED on the breadboard
Connect an LED on the breadboard: the long (positive) leg to pin 9 through a 220-ohm resistor, and the short leg to GND. Then change LED_BUILTIN in the program to the number 9. Why the resistor? We explained the calculation in circuit basics.
Traffic lights
Three LEDs – red, amber and green – on three pins, each with its own resistor. In loop: green for a few seconds, then amber for two seconds, then red for a few seconds. An enjoyable project that teaches sequence and timing.
A button that controls the LED
Connect a button between a digital pin and GND, and set the pin in setup to INPUT_PULLUP, which makes the pin read HIGH when the button is released and LOW when it is pressed. Then use digitalRead with an if statement: if the button is pressed, light the LED. Here you move from a program that repeats something fixed to a device that responds to what happens around it – the idea we build on in sensors in robots.
Let the board talk to you: the Serial Monitor
As your program grows you will need to know what is happening inside it. Add the line Serial.begin(9600); in setup, then write Serial.println("...") anywhere to print a message or a variable’s value. Next, open the Serial Monitor from the Tools menu and choose the same speed, 9600, and you will see the messages arriving from the board moment by moment. It is the most important tool for finding errors in Arduino projects, and you will use it constantly when reading sensors.
Fixing common problems
| Problem | Likely cause | Fix |
|---|---|---|
| The port does not appear in the list | A charge-only cable, or a missing driver | Try another cable that carries data, and install the right driver for the board |
| An error during upload | The wrong board or port in the settings | Make sure Arduino Uno and the correct port are selected |
| A message mentioning a semicolon | A missing semicolon on the previous line | Check the end of the line mentioned and the line before it |
| The external LED does not light | The LED is reversed or wired into the wrong row | Turn the LED round and check the breadboard rows |
| The LED is very dim | A missing pinMode, or too large a resistor | Make sure the pin is set as an output, and check the resistor value |
Good habits from day one
- Save every project in a clearly named folder, and do not edit the original examples.
- Write comments explaining what each part does and why.
- Change one thing at a time, then test, so you know the effect of each change.
- Draw the circuit on paper before wiring it.
If you have not met the board yet, start with what is Arduino. Once you have mastered blinking and buttons, you are ready for motors, as in motors in robots. In the robotics and embedded systems course at Badr Academy Education we progress from this first program to a complete robot, with follow-up from the instructor. For further resources visit the learning library, and try the Find your path tool.
The takeaway
Every Arduino program consists of setup, which runs once, and loop, which repeats without stopping. Install the environment, choose the board and port, write the blink program and understand every line, then develop it with an external LED, traffic lights and a button. Every big project starts with a small blinking light.
© 2026 Badr Academy Education – this content is exclusive to Badr Academy Education. Short quotations are welcome with the source and a link to this page.
Category: Robotics & electronics
Comments (0)
You can comment without an account; your comment appears after review, and the academy may edit it before publishing.
No comments yet – be the first to join in.


Add a comment