Setup, Safety & Hardware
Before a learner writes code, they need to know what is safe to plug in, what parts they are holding, and how Arduino differs from a Raspberry Pi.
- Identify the Arduino board, USB port, power pins, digital pins, analog pins, and reset button.
- Explain the difference between a microcontroller and a Linux computer.
- Build a safe beginner parts kit and avoid wiring mistakes that can damage hardware.
Arduino
Runs one program directly on a microcontroller. Excellent for simple, reliable hardware control.
Raspberry Pi
Runs a full Linux operating system. Excellent for servers, cameras, dashboards, networking, and heavier software.
| Part | Why it matters |
|---|---|
| Arduino Uno or compatible board | The main controller. The Uno layout is beginner-friendly and widely supported. |
| Breadboard + jumper wires | Lets learners build circuits without soldering. |
| LEDs + 220Ω/330Ω resistors | First output circuit and current-limiting practice. |
| Pushbuttons | First digital input component. |
| Potentiometer | First analog input component. |
| Buzzer, LDR, temperature sensor | Small parts that make final projects feel alive. |
Electricity Basics
Voltage, current, resistance, polarity, and ground explained with the exact level of depth a beginner needs before wiring components.
- Voltage is electrical pressure. It pushes current through a circuit.
- Current is the flow of electric charge. Too much current can burn components.
- Resistance limits current. Resistors protect LEDs and input circuits.
You do not need to become an electrical engineer before building. You do need one formula:
Voltage = Current × Resistance V = I × R
Example: if an LED circuit uses 5V and a safe current is around 0.02A, a resistor is used to keep current from running wild. In beginner Arduino LED circuits, 220Ω or 330Ω is a safe default.
- Draw a battery, resistor, LED, and ground path on paper.
- Use arrows to show current flow from positive to ground.
- Label where the resistor protects the LED.
Breadboards & LEDs
Learners assemble their first circuit, understand connected rows, and make an LED blink from a digital pin.
- Rows on each side of the center gap are connected in small groups.
- The center gap separates the two halves of the board.
- Power rails are used to distribute 5V and GND, but some breadboards split rails in the middle.
- Connect Arduino GND to the breadboard ground rail.
- Place the LED across separate breadboard rows.
- Connect the LED's short leg to GND.
- Connect the LED's long leg through a 220Ω or 330Ω resistor to digital pin 13.
- Upload the Blink sketch.
const int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}
Arduino Sketches
A beginner-friendly introduction to Arduino code structure, variables, constants, setup, loop, comments, and compile errors.
setup()
Runs once when the board powers on or resets. Use it for pin modes and starting tools like Serial.
loop()
Runs forever after setup. Use it for repeated behavior: read inputs, make decisions, control outputs.
const int ledPin = 9; // constant pin number
int blinkDelay = 250; // variable value
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(blinkDelay);
digitalWrite(ledPin, LOW);
delay(blinkDelay);
}| Error | Likely cause |
|---|---|
| expected ';' | Missing semicolon at the end of a statement. |
| not declared in this scope | Misspelled variable or variable created in the wrong place. |
| expected '}' | Missing closing brace after setup, loop, or an if statement. |
Change the code so the LED blinks two fast pulses, waits one second, then repeats. This teaches sequence thinking and timing.
Digital Input
Buttons teach learners the core embedded pattern: read an input, decide what it means, then control an output.
A pushbutton is a switch. When pressed, it connects two sides of a circuit. When released, it opens the circuit. The Arduino needs a clean HIGH or LOW signal, not a floating unknown signal.
const int buttonPin = 2;
const int ledPin = 13;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
}
void loop() {
int pressed = digitalRead(buttonPin) == LOW;
digitalWrite(ledPin, pressed ? HIGH : LOW);
}
- Wire one side of a button to digital pin 2.
- Wire the other side to GND.
- Upload the sketch above.
- Confirm the LED lights only while the button is pressed.
Analog Input
Analog input turns real-world variation into numbers. This is the doorway to knobs, light sensors, temperature sensors, and responsive devices.
On classic Arduino Uno-style boards, analog input reads a value from 0 to 1023. A potentiometer is the easiest first analog sensor because learners can turn it by hand and see the value change immediately.
const int knobPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int value = analogRead(knobPin);
Serial.println(value);
delay(100);
}
Raw sensor values are rarely the final behavior. The maker's job is to map a reading to an output.
int sensor = analogRead(A0); int brightness = map(sensor, 0, 1023, 0, 255);
Use a potentiometer on A0 to control LED brightness on a PWM pin. This connects analog input to visible output.
PWM & Output Control
Pulse-width modulation makes digital pins act like variable outputs for brightness, simple motor speed control, and buzzer effects.
An Arduino digital pin can only be ON or OFF, but PWM switches it on and off very quickly. Changing how long it stays on changes the average power a component receives.
const int ledPin = 9;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
for (int level = 0; level <= 255; level++) {
analogWrite(ledPin, level);
delay(8);
}
}
Wire an LED to a PWM-capable pin through a resistor, then fade it smoothly from off to bright.
Serial Debugging
Learners stop guessing and start inspecting. Serial output is the beginner's first embedded debugging tool.
When a circuit acts wrong, beginners often stare at wires and hope. The Serial Monitor lets them print what the board is reading and what decisions the code is making.
void setup() {
Serial.begin(9600);
}
void loop() {
int light = analogRead(A0);
Serial.print("Light value: ");
Serial.println(light);
delay(250);
}
- Print sensor values before using them in logic.
- Print button state to confirm wiring.
- Print which branch an if statement enters.
- Reduce delays while debugging so feedback feels instant.
Intentionally wire a button, print its state, then fix the wiring or code until the serial output changes exactly when pressed.
Sensors & Modules
This module moves from single components to small modules: light sensing, sound output, distance sensing, and status indicators.
Most Arduino sensor projects follow the same loop:
read sensor → clean value → compare threshold → control output → print debug info
LDR / Photoresistor
Detects light level. Great for night-light projects and alarms.
Ultrasonic Sensor
Measures distance using sound pulses. Great for parking assistants and motion triggers.
Buzzer
Makes sound for alarms, timers, and feedback.
RGB LED
Shows device state with color: armed, warning, triggered, idle.
int light = analogRead(A0);
if (light < 300) {
// room is dark
} else {
// room is bright
}- Read an LDR value on A0.
- Print the raw value to Serial.
- Choose a threshold.
- Turn an LED on automatically when the room gets dark.
Capstone: Mini Room Alarm
The final build combines digital input, analog input, PWM output, serial debugging, and sensor thresholds into a portfolio-ready beginner device.
Build a small room-entry alarm that can be armed with a button, triggered by a sensor, and communicate its state with an LED and buzzer.
- Arduino Uno or compatible board
- Breadboard and jumper wires
- Pushbutton
- LED or RGB LED + resistors
- Buzzer
- LDR or ultrasonic sensor
| State | Behavior |
|---|---|
| Idle | System is not armed. LED is off or dim. |
| Armed | Button has armed the system. LED shows ready state. |
| Triggered | Sensor crosses threshold. Buzzer sounds and LED flashes. |
| Reset | Button press returns the alarm to idle. |
// Capstone starter structure
bool armed = false;
bool triggered = false;
void setup() {
Serial.begin(9600);
// configure pins here
}
void loop() {
// 1. read button
// 2. read sensor
// 3. update armed/triggered state
// 4. control LED and buzzer
// 5. print debug info
}
- Draw the wiring diagram.
- Write the final sketch with comments.
- Add a troubleshooting section.
- Record a short demo video.
- Write a README explaining what the device does and how to rebuild it.