All courses
Arduino & Electronics
Arduino and Electronics

A full starter-kit course. A clear lecture and a working project for every component in your Arduino Uno kit, from the first blinking LED to sensors, displays and motors, plus the electronics to understand them. Open to complete beginners.

01
Start
02
Your Kit
03
Electronics
04
Code
05
Light
06
Sound
07
Buttons
08
Sensors
09
Distance
10
Climate
11
Motors
12
Modules
13
Projects
14
Debug
Intro
What an Arduino is

An Arduino is a small, cheap computer on a board that you program to control electronics. It reads inputs (buttons, sensors) and drives outputs (LEDs, motors, displays). The Uno is the most common board and the one your starter kit is built around.

Unlike a laptop, it runs one program at a time, called a sketch, and it runs it the moment it powers on. You write the sketch on your computer and upload it to the board.

The board
A tour of the Uno
The Arduino Uno board
The Arduino Uno board

The parts you will use most:

  • USB port: carries power and uploads your sketch from the computer
  • Digital pins 0 to 13: on/off pins. The ones marked with a tilde (3, 5, 6, 9, 10, 11) can also do PWM
  • Analog pins A0 to A5: read a range of voltage, for sensors and knobs
  • Power pins: 5V, 3.3V and GND (ground). Almost everything needs a GND connection
  • Built-in LED: a small LED wired to pin 13, handy for a first test
Software
The IDE and uploading

You write and upload sketches with the free Arduino IDE. Install it, plug in the board, then in the Tools menu pick the board (Arduino Uno) and the port. Write your sketch and press Upload.

No board yet? Go to wokwi.com, a free online Arduino simulator. You can build and run every project in this course in your browser, wiring and all, before you buy anything.
Sketch structure
setup and loop

Every sketch has two functions. setup() runs once when the board powers on, for one-time jobs like setting pins. loop() runs over and over, forever, and holds the main work.

Arduino
void setup() {
  // runs once at the start
}

void loop() {
  // runs again and again, forever
}
First sketch
Blink the built-in LED

The hello world of hardware. It blinks the LED on pin 13 with no wiring at all.

Arduino
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);   // set the pin as an output
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // LED on
  delay(1000);                      // wait 1 second
  digitalWrite(LED_BUILTIN, LOW);   // LED off
  delay(1000);                      // wait 1 second
}
pinMode
tell the board a pin is an output or input
digitalWrite
set an output pin HIGH (on) or LOW (off)
delay(1000)
wait, in milliseconds, so 1000 is one second
Upload this first. A blinking light proves your board, cable and software all work before you wire anything.
Inventory
What is in the box
A typical Arduino Uno starter kit
A typical Arduino Uno starter kit

Your kit is a box of parts that fall into three groups: the brain (the Uno), outputs that make something happen, and inputs that sense the world. Plus the glue: a breadboard, wires and resistors to connect it all. This course has a lecture and a working project for each part. Open your kit and find each one as we name it.

Inventory
Board, wiring and passives
PartWhat it does
Arduino Unothe programmable brain
Breadboarda board to build circuits without soldering
Jumper wiresconnect points on the breadboard and the Uno
USB cablepower and upload
Resistorslimit current, protect LEDs and set levels
Capacitorsstore and smooth small amounts of charge
Diodeslet current flow one way only
Transistora tiny switch the Arduino uses to control bigger loads
Inventory
Outputs: things that act
PartWhat it does
LEDssmall lights, your main output for learning
RGB LEDone LED that mixes red, green and blue
Buzzermakes a tone or beep
7-segment displayshows a digit 0 to 9
LCD1602 (I2C)a 2-line text screen
LED matrix / barrows of LEDs for patterns
Servo motorturns to an exact angle
DC motor + driverspins a wheel or fan
Stepper motor + driverturns in precise steps
Relayswitches a bigger, mains-level load on and off
Inventory
Inputs: things that sense
PartWhat it senses
Push buttona press (on or off)
Potentiometerthe position of a knob
Photoresistor (LDR)how much light
Thermistortemperature, as a resistance
DHT11temperature and humidity together
Ultrasonic HC-SR04distance to an object
PIR sensormovement of a warm body
Sound sensornoise level
IR receiver + remotebutton presses from a remote
Joystickdirection in two axes
Tilt / flame / water sensorstilt, flame, water level
You do not need every part at once. Each lecture tells you exactly which pieces to pull out for that project.
Breadboard
Building without soldering

A breadboard lets you push parts and wires into holes that are connected underneath, so you can build and change circuits fast. Two things to know: the long rails on the sides (marked + and -) run the full length and carry power and ground. The short rows in the middle are connected across in groups, split by the centre gap.

The centre gap matters. A part that straddles the gap has each side on a separate row. A part on one side of the gap shares that row with whatever else is in it.
Basics
Voltage, current and resistance

Think of electricity like water in a pipe.

Voltage (V)
the push, like water pressure. The Uno gives 5V.
Current (I)
the flow, how much is moving. Measured in amps, or milliamps (mA).
Resistance (R)
how much the pipe fights the flow. Measured in ohms.
Basics
Ohm's law

The one formula that ties them together: V = I * R. Rearranged, I = V / R. More resistance means less current. This is why an LED needs a resistor: without one, too much current flows and the LED burns out.

Working
Current = Voltage / Resistance
Example: 5V / 220 ohms = 0.023 A = 23 mA
Resistors
Reading the colour bands

Resistors show their value as coloured bands. The common ones in your kit:

ValueCommon useFirst bands
220 ohmin series with an LEDred red brown
1 kgeneral limitingbrown black red
10 kpull-up/down, sensorsbrown black orange
You do not have to memorise the code. A multimeter reads any resistor's value in a second.
Circuits
Series and parallel

In series, current has one path, so the same current flows through every part and the voltage splits. In parallel, there are several paths, so each part gets the full voltage and the current splits. Parts in series share the voltage, parts in parallel share the current.

Circuits
Pull-up and pull-down resistors

A digital input connected to nothing is floating and reads random noise. A resistor ties it to a known level: a pull-down to GND reads LOW until pressed, a pull-up to 5V reads HIGH until pressed. The Arduino has pull-ups built in, so pinMode(pin, INPUT_PULLUP) saves you a resistor.

Power
Limits, and protecting the board

Each Arduino pin gives only about 20 mA, enough for an LED, not a motor. Rules that save boards:

  • always put a resistor (around 220 ohm) in series with an LED
  • never drive a motor straight from a pin, use a transistor or a driver module
  • join grounds: every part must share a common GND with the Arduino
Connecting 5V straight to GND, or a motor straight to a pin, is the quickest way to kill a board.
Parts
Capacitor, diode, transistor
Capacitor
stores a little charge and smooths out sudden dips, like a small water tank.
Diode
a one-way valve for current. It protects circuits from reversed power and voltage spikes from motors.
Transistor
a tiny electronic switch. A small signal from the Arduino lets it switch a much bigger current, which is how the Arduino controls motors and relays.
Tools
The multimeter

One cheap tool saves hours. It measures voltage (probes across a part), continuity (beeps if two points connect, great for finding breaks), and resistance (reads a resistor's value).

Language
Arduino code is C

Every sketch is written in C, the same language as the C Programming course on this site. If the syntax feels shaky, do that course alongside this one. Here are the Arduino-specific functions you use to talk to the pins.

Pins
pinMode, digitalWrite, digitalRead

pinMode(pin, OUTPUT) or INPUT sets a pin's job. digitalWrite(pin, HIGH/LOW) turns an output on or off. digitalRead(pin) reads an input as HIGH or LOW.

Arduino
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);        // pin 8 on

pinMode(2, INPUT_PULLUP);
int pressed = digitalRead(2); // LOW when the button is pressed
Analog
analogRead and analogWrite

analogRead(A0) reads a sensor or knob as a number from 0 to 1023. analogWrite(pin, value) sends a PWM level from 0 to 255 on a tilde pin, for brightness or speed.

Arduino
int raw = analogRead(A0);    // 0 to 1023
int level = map(raw, 0, 1023, 0, 255);
analogWrite(9, level);       // brightness follows the knob
Timing
delay and millis

delay(ms) pauses everything for a number of milliseconds. It is simple but it blocks the whole program. millis() returns the time since the board started, which lets you time things without freezing the sketch. Start with delay, learn millis when you need two things to happen at once.

Serial
Talking to your computer

Serial.begin(9600) in setup opens a link to the computer. Serial.print and Serial.println send values you can watch live in the Serial Monitor. This is your main debugging tool.

Arduino
void setup() { Serial.begin(9600); }
void loop() {
  Serial.println(analogRead(A0));
  delay(300);
}
Helpers
map and constrain

map(value, inLow, inHigh, outLow, outHigh) rescales a number from one range to another. constrain(value, low, high) clamps it so it never goes out of range. Together they keep sensor readings in the range your output needs.

For variables, loops, functions and the rest of the C language, the C Programming course on this site goes deep. This course focuses on the hardware.
Component
LED
A small light, and your main learning output. It has a long leg (+, anode) and a short leg (-, cathode), and it always needs a resistor in series.
LED
Blink an external LED
Single LED
Arduino Component ------- --------- D9 -> LED long leg, through a 220 ohm resistor GND -> LED short leg
Arduino
int led = 9;
void setup() { pinMode(led, OUTPUT); }
void loop() {
  digitalWrite(led, HIGH); delay(500);
  digitalWrite(led, LOW);  delay(500);
}
The resistor is not optional. Without it the LED pulls too much current and burns out, and can damage the pin.
LEDs
Project: traffic light

Three LEDs, red, yellow and green, cycled like a traffic light. A clean first multi-output project.

Traffic light
Arduino Component ------- --------- D10 -> red LED (via 220 ohm) D9 -> yellow LED (via 220 ohm) D8 -> green LED (via 220 ohm) GND -> all short legs
Arduino
int red = 10, yellow = 9, green = 8;
void setup() {
  pinMode(red, OUTPUT); pinMode(yellow, OUTPUT); pinMode(green, OUTPUT);
}
void loop() {
  digitalWrite(green, HIGH); delay(3000); digitalWrite(green, LOW);
  digitalWrite(yellow, HIGH); delay(1000); digitalWrite(yellow, LOW);
  digitalWrite(red, HIGH); delay(3000); digitalWrite(red, LOW);
}
Component
RGB LED
Three LEDs (red, green, blue) in one package. Drive each with PWM and you can mix almost any colour.
RGB LED
Mix colours
RGB LED (common cathode)
Arduino Component ------- --------- D9 -> red leg (via 220 ohm) D10 -> green leg (via 220 ohm) D11 -> blue leg (via 220 ohm) GND -> common leg
Arduino
int R = 9, G = 10, B = 11;
void setColor(int r, int g, int b) {
  analogWrite(R, r); analogWrite(G, g); analogWrite(B, b);
}
void setup() {
  pinMode(R, OUTPUT); pinMode(G, OUTPUT); pinMode(B, OUTPUT);
}
void loop() {
  setColor(255, 0, 0);   delay(500);   // red
  setColor(0, 255, 0);   delay(500);   // green
  setColor(0, 0, 255);   delay(500);   // blue
  setColor(255, 150, 0); delay(500);   // amber
}
Component
7-segment display
Seven LEDs (a to g) arranged to show a digit 0 to 9. Light the right segments and a number appears.
7-segment
Show the digits 0 to 9

Each segment is an LED with its own pin. A pattern table says which segments light for each digit.

7-segment (common cathode)
Arduino Component ------- --------- D2..D8 -> segments a to g, each via 220 ohm GND -> common cathode pin
Arduino
int seg[7] = {2, 3, 4, 5, 6, 7, 8};   // a b c d e f g
byte digit[10][7] = {
  {1,1,1,1,1,1,0}, {0,1,1,0,0,0,0}, {1,1,0,1,1,0,1}, {1,1,1,1,0,0,1},
  {0,1,1,0,0,1,1}, {1,0,1,1,0,1,1}, {1,0,1,1,1,1,1}, {1,1,1,0,0,0,0},
  {1,1,1,1,1,1,1}, {1,1,1,1,0,1,1}
};
void show(int n) {
  for (int i = 0; i < 7; i++) digitalWrite(seg[i], digit[n][i]);
}
void setup() {
  for (int i = 0; i < 7; i++) pinMode(seg[i], OUTPUT);
}
void loop() {
  for (int n = 0; n < 10; n++) { show(n); delay(1000); }
}
Build it
Build an electronic dice: show a random number from 1 to 6 on the display, with a short countdown of changing digits first.
Hint: use random(1, 7) and the show function above.
Component
Buzzer
Makes sound. An active buzzer beeps on its own when powered. A passive buzzer plays whatever pitch you give it with tone(), so it can play melodies.
Buzzer
Beep with an active buzzer
Active buzzer
Arduino Component ------- --------- D8 -> buzzer + GND -> buzzer -
Arduino
int buzzer = 8;
void setup() { pinMode(buzzer, OUTPUT); }
void loop() {
  digitalWrite(buzzer, HIGH); delay(300);
  digitalWrite(buzzer, LOW);  delay(300);
}
Buzzer
Play tones with a passive buzzer

tone(pin, frequency) plays a pitch, noTone(pin) stops it. Higher frequency, higher note.

Arduino
int buzzer = 8;
int notes[] = {262, 294, 330, 349, 392};  // C D E F G
void setup() {}
void loop() {
  for (int i = 0; i < 5; i++) {
    tone(buzzer, notes[i]);
    delay(300);
  }
  noTone(buzzer);
  delay(1000);
}
Build it
Make an alarm that rises and falls in pitch, like a siren.
Then combine a buzzer with a button to make a one-key piano, or with the LEDs for a sound-and-light alarm.
Component
Push button
A switch that connects while you hold it. With the built-in pull-up, the pin reads HIGH when open and LOW when pressed.
Button
Read a press
Push button
Arduino Component ------- --------- D2 -> one leg of the button GND -> the other leg
Arduino
int button = 2, led = 13;
void setup() {
  pinMode(button, INPUT_PULLUP);
  pinMode(led, OUTPUT);
}
void loop() {
  if (digitalRead(button) == LOW) {   // LOW means pressed
    digitalWrite(led, HIGH);
  } else {
    digitalWrite(led, LOW);
  }
}
Button
Press once: toggle and debounce

The loop runs thousands of times a second, so one press looks like many. Watch for the change from open to pressed, and add a small delay to settle the contact.

Arduino
int button = 2, led = 13;
int last = HIGH; bool on = false;
void setup() { pinMode(button, INPUT_PULLUP); pinMode(led, OUTPUT); }
void loop() {
  int now = digitalRead(button);
  if (last == HIGH && now == LOW) {   // just pressed
    on = !on;                         // flip the state
    digitalWrite(led, on);
    delay(20);                        // debounce
  }
  last = now;
}
Component
Tilt switch
A small switch with a ball inside. Tilt it and the ball closes the contact, so the Arduino can tell when something is tipped or shaken.
Tilt switch
Sense orientation
Tilt switch
Arduino Component ------- --------- D3 -> one leg GND -> other leg
Arduino
int tilt = 3, buzzer = 8;
void setup() { pinMode(tilt, INPUT_PULLUP); pinMode(buzzer, OUTPUT); }
void loop() {
  if (digitalRead(tilt) == LOW) {     // tilted
    tone(buzzer, 1000);
  } else {
    noTone(buzzer);
  }
}
Build it
Make a button that counts presses and shows the count on the Serial Monitor.
Then make a tilt alarm that beeps and flashes an LED whenever the board is moved.
Component
Potentiometer
A knob that gives a value from 0 to 1023 as you turn it. The simplest analog input, perfect for learning analogRead.
Potentiometer
Project: an LED dimmer
Potentiometer
Arduino Component ------- --------- 5V -> one outer leg GND -> other outer leg A0 -> middle leg
Arduino
int led = 9;
void setup() { pinMode(led, OUTPUT); }
void loop() {
  int raw = analogRead(A0);              // 0 to 1023
  int level = map(raw, 0, 1023, 0, 255);
  analogWrite(led, level);               // brightness follows the knob
}
Component
Photoresistor (LDR)
A resistor whose value changes with light. Wired as a voltage divider, it lets the Arduino measure brightness.
LDR
Project: automatic night light
LDR divider
Arduino Component ------- --------- 5V -> one leg of the LDR A0 -> junction of LDR and 10k resistor GND -> other end of the 10k resistor
Arduino
int led = 9;
void setup() { pinMode(led, OUTPUT); Serial.begin(9600); }
void loop() {
  int light = analogRead(A0);
  Serial.println(light);
  if (light < 300) {           // dark
    digitalWrite(led, HIGH);   // turn the light on
  } else {
    digitalWrite(led, LOW);
  }
  delay(200);
}
Cover the LDR with your hand and watch the number drop in the Serial Monitor. Adjust the 300 threshold to suit your room.
Component
Thermistor
A resistor whose value changes with temperature. Like the LDR, it is read as a voltage divider, then converted to degrees.
Thermistor
Read the temperature
Thermistor divider
Arduino Component ------- --------- 5V -> one leg of the thermistor A0 -> junction of thermistor and 10k resistor GND -> other end of the 10k resistor
Arduino
#include <math.h>
void setup() { Serial.begin(9600); }
void loop() {
  int raw = analogRead(A0);
  float r = 10000.0 * raw / (1023.0 - raw);        // thermistor resistance
  float tempK = 1.0 / (log(r / 10000.0) / 3950.0 + 1.0 / 298.15);
  float tempC = tempK - 273.15;
  Serial.print("Temp: "); Serial.println(tempC);
  delay(500);
}

The numbers (10000, 3950) are for a common 10k NTC thermistor. Different thermistors need different values, printed on the datasheet.

Component
Joystick
Two potentiometers and a button in one. It gives an X value, a Y value and a press, for direction control.
Joystick
Read direction and press
Joystick
Arduino Component ------- --------- 5V -> +5V GND -> GND A0 -> VRx (left-right) A1 -> VRy (up-down) D2 -> SW (press)
Arduino
void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT_PULLUP);
}
void loop() {
  int x = analogRead(A0);
  int y = analogRead(A1);
  int pressed = (digitalRead(2) == LOW);
  Serial.print(x); Serial.print(" "); Serial.print(y);
  Serial.print(" "); Serial.println(pressed);
  delay(200);
}
Build it
Make an LED bar graph: as the potentiometer turns, light more LEDs.
Then build a night light that only comes on when it is both dark (LDR) and someone is there (add the PIR sensor from the next topic).
Component
Ultrasonic HC-SR04
Measures distance by sending a sound pulse and timing the echo, like a bat. Good from about 2 cm to 4 m.
HC-SR04
Measure distance
HC-SR04
Arduino Component ------- --------- 5V -> VCC GND -> GND D9 -> Trig D10 -> Echo
Arduino
int trig = 9, echo = 10;
void setup() {
  pinMode(trig, OUTPUT); pinMode(echo, INPUT);
  Serial.begin(9600);
}
void loop() {
  digitalWrite(trig, LOW);  delayMicroseconds(2);
  digitalWrite(trig, HIGH); delayMicroseconds(10);
  digitalWrite(trig, LOW);
  long dur = pulseIn(echo, HIGH);
  long cm = dur * 0.034 / 2;          // speed of sound, there and back
  Serial.print(cm); Serial.println(" cm");
  delay(200);
}
HC-SR04
Project: reverse parking sensor

The closer an object, the faster the buzzer beeps. The same idea as a car parking sensor.

Arduino
int trig = 9, echo = 10, buzzer = 8;
void setup() { pinMode(trig, OUTPUT); pinMode(echo, INPUT); pinMode(buzzer, OUTPUT); }
long readCm() {
  digitalWrite(trig, LOW);  delayMicroseconds(2);
  digitalWrite(trig, HIGH); delayMicroseconds(10); digitalWrite(trig, LOW);
  return pulseIn(echo, HIGH) * 0.034 / 2;
}
void loop() {
  long cm = readCm();
  if (cm < 30) {
    tone(buzzer, 1000);
    delay(map(cm, 0, 30, 50, 500));   // closer = shorter gap
    noTone(buzzer);
    delay(map(cm, 0, 30, 50, 500));
  } else {
    noTone(buzzer);
  }
}
Component
PIR motion sensor
Detects the movement of a warm body (a person) nearby. Its pin goes HIGH when it sees motion.
PIR
Project: motion alarm
PIR sensor
Arduino Component ------- --------- 5V -> VCC GND -> GND D2 -> OUT
Arduino
int pir = 2, led = 13, buzzer = 8;
void setup() {
  pinMode(pir, INPUT); pinMode(led, OUTPUT); pinMode(buzzer, OUTPUT);
}
void loop() {
  if (digitalRead(pir) == HIGH) {     // motion
    digitalWrite(led, HIGH);
    tone(buzzer, 1200);
  } else {
    digitalWrite(led, LOW);
    noTone(buzzer);
  }
}
Component
Flame and water sensors
The flame sensor spots the infrared light of a fire. The water sensor reads how deep it is wet. Both are read like the LDR, by threshold.
Flame / water
Threshold sensing
Arduino
int flame = A0;   // or a digital OUT pin
void setup() { Serial.begin(9600); }
void loop() {
  int value = analogRead(flame);
  Serial.println(value);
  if (value < 200) {                  // strong signal
    Serial.println("Warning detected");
  }
  delay(300);
}
Every threshold sensor works the same way: read the number, watch it in the Serial Monitor, then pick a cut-off that fits your setup.
Build it
Build a complete security post: the PIR senses a person, the buzzer sounds, and an LED flashes.
Then add the ultrasonic sensor so it also announces how close they are.
Component
DHT11
Reads temperature and humidity together in one small sensor. Needs the DHT library (install it in the Arduino IDE).
DHT11
Temperature and humidity
The DHT11 temperature and humidity sensor
The DHT11 temperature and humidity sensor
DHT11
Arduino Component ------- --------- 5V -> VCC (+) GND -> GND (-) D2 -> DATA
Arduino
#include <DHT.h>
DHT dht(2, DHT11);

void setup() {
  Serial.begin(9600);
  dht.begin();
}
void loop() {
  float t = dht.readTemperature();
  float h = dht.readHumidity();
  Serial.print(t); Serial.print(" C   ");
  Serial.print(h); Serial.println(" %");
  delay(1000);
}
Component
LCD1602 (I2C)
A 2-line, 16-character text screen. The I2C version uses just two data pins. Needs the LiquidCrystal_I2C library.
LCD1602
Show text on the screen
The 16x2 I2C LCD display
The 16x2 I2C LCD display
I2C LCD
Arduino Component ------- --------- 5V -> VCC GND -> GND A4 -> SDA A5 -> SCL
Arduino
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);   // address is often 0x27 or 0x3F

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("TechCamp");
  lcd.setCursor(0, 1);
  lcd.print("Hello, Ghana");
}
void loop() {}
If the screen stays blank, the address is usually the problem. Try 0x3F instead of 0x27, or run an I2C scanner sketch to find it.
Project
A simple weather station

Put the DHT11 and the LCD together: read the temperature and humidity, and show them on the screen. This is a genuinely useful build.

Arduino
#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
DHT dht(2, DHT11);
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  dht.begin(); lcd.init(); lcd.backlight();
}
void loop() {
  float t = dht.readTemperature();
  float h = dht.readHumidity();
  lcd.setCursor(0, 0); lcd.print("Temp: "); lcd.print(t); lcd.print(" C");
  lcd.setCursor(0, 1); lcd.print("Humidity: "); lcd.print(h); lcd.print("%");
  delay(1000);
}
Component
LED matrix (MAX7219)
An 8 by 8 grid of LEDs driven by one chip, for patterns, icons and scrolling text. Needs the LedControl library.
LED matrix
Light a pattern
8x8 matrix
Arduino Component ------- --------- 5V -> VCC GND -> GND D12 -> DIN D11 -> CLK D10 -> CS
Arduino
#include <LedControl.h>
LedControl lc(12, 11, 10, 1);   // DIN, CLK, CS, one device

void setup() {
  lc.shutdown(0, false);
  lc.setIntensity(0, 8);
  lc.clearDisplay(0);
}
void loop() {
  for (int row = 0; row < 8; row++) lc.setRow(0, row, B10101010);
  delay(500);
  lc.clearDisplay(0);
  delay(500);
}
Build it
Make the weather station show a smiley on the matrix when humidity is comfortable and a frown when it is too high.
Then add a button to switch the LCD between temperature and humidity screens.
Component
Servo (SG90)
A motor that turns to an exact angle from 0 to 180 degrees and holds it. Great for arms, gates and dials. Needs the Servo library (built in).
Servo
Turn to an angle
SG90 servo
Arduino Component ------- --------- D9 -> signal (orange) 5V -> power (red) GND -> ground (brown)
Arduino
#include <Servo.h>
Servo myServo;
void setup() { myServo.attach(9); }
void loop() {
  myServo.write(0);    delay(1000);
  myServo.write(90);   delay(1000);
  myServo.write(180);  delay(1000);
}
A servo can pull more current than the USB port gives. If it twitches or the board resets, power the servo from a separate 5V supply and join the grounds.
Servo
Project: servo follows a knob
Arduino
#include <Servo.h>
Servo myServo;
void setup() { myServo.attach(9); }
void loop() {
  int angle = map(analogRead(A0), 0, 1023, 0, 180);
  myServo.write(angle);
  delay(20);
}
Component
DC motor + L293D
A plain spinning motor. It needs more current than a pin can give, so a driver chip (L293D) sits between the Arduino and the motor to control speed and direction.
DC motor
Spin, with speed and direction
DC motor via L293D
Arduino Component ------- --------- D9 -> EN (enable, PWM for speed) D4 -> IN1 (direction) D5 -> IN2 (direction) GND -> driver and motor ground
Arduino
int en = 9, in1 = 4, in2 = 5;
void setup() {
  pinMode(en, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT);
}
void loop() {
  digitalWrite(in1, HIGH); digitalWrite(in2, LOW);   // forward
  analogWrite(en, 200);    delay(2000);              // speed 0 to 255
  analogWrite(en, 0);      delay(1000);              // stop
  digitalWrite(in1, LOW);  digitalWrite(in2, HIGH);  // reverse
  analogWrite(en, 200);    delay(2000);
  analogWrite(en, 0);      delay(1000);
}
Component
Stepper + ULN2003
A motor that turns in precise, countable steps, so you can rotate an exact amount. The 28BYJ-48 with its ULN2003 driver board is the common kit stepper.
Stepper
Turn exact steps
28BYJ-48 via ULN2003
Arduino Component ------- --------- D8 -> IN1 D10 -> IN2 D9 -> IN3 D11 -> IN4 5V -> driver + GND -> driver -
Arduino
#include <Stepper.h>
Stepper motor(2048, 8, 10, 9, 11);   // 2048 steps per turn

void setup() { motor.setSpeed(10); }  // rpm
void loop() {
  motor.step(2048);    // one full turn, one way
  delay(1000);
  motor.step(-2048);   // one full turn, the other way
  delay(1000);
}
Build it
Build a radar: sweep the servo back and forth with the ultrasonic sensor on top, and print the distance at each angle.
Then make a fan whose speed follows the potentiometer, using the DC motor.
Component
IR receiver + remote
Reads the button presses from an infrared remote, so a remote can control your project. Needs the IRremote library.
IR remote
Read remote buttons
IR receiver
Arduino Component ------- --------- 5V -> VCC GND -> GND D2 -> signal (OUT)
Arduino
#include <IRremote.h>
IRrecv irrecv(2);
decode_results results;
void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn();
}
void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);   // the code of the pressed button
    irrecv.resume();
  }
}
Press each remote button once and note its code from the Serial Monitor. Then your sketch can react to each button by its code.
Component
74HC595 shift register
A chip that turns 3 Arduino pins into 8 outputs. Perfect when you run out of pins and need to drive many LEDs.
Shift register
Drive 8 LEDs with 3 pins
74HC595
Arduino Component ------- --------- D11 -> DS (data) D12 -> STCP (latch) D8 -> SHCP (clock) 5V -> VCC and MR GND -> GND and OE
Arduino
int data = 11, latch = 12, clock = 8;
void setup() {
  pinMode(data, OUTPUT); pinMode(latch, OUTPUT); pinMode(clock, OUTPUT);
}
void show(byte pattern) {
  digitalWrite(latch, LOW);
  shiftOut(data, clock, MSBFIRST, pattern);   // 8 bits, 8 LEDs
  digitalWrite(latch, HIGH);
}
void loop() {
  show(B10101010); delay(400);
  show(B01010101); delay(400);
}
Component
Relay module
An electrically controlled switch. A tiny signal from the Arduino switches a much larger load on or off, like a lamp or a pump.
Relay
Switch a bigger load
Relay module
Arduino Component ------- --------- 5V -> VCC GND -> GND D7 -> IN (control)
Arduino
int relay = 7;
void setup() { pinMode(relay, OUTPUT); }
void loop() {
  digitalWrite(relay, HIGH); delay(2000);   // load on
  digitalWrite(relay, LOW);  delay(2000);   // load off
}
A relay can switch mains electricity, which is dangerous. Practise with low-voltage loads (an LED strip, a small bulb) and do not wire mains unless a qualified person supervises you.
Component
RTC (DS1307)
A real-time clock that keeps the date and time running on its own battery, even when the Arduino is off. Needs the RTClib library.
RTC
Keep real time

Wired over I2C like the LCD (SDA to A4, SCL to A5). After setting it once, it keeps time by itself. Useful for data loggers and alarms that must know the actual time of day.

Build it
Use the IR remote to turn the relay on and off, so one remote button switches a lamp.
Then drive all 8 shift-register LEDs as a running light that chases back and forth.
Capstone
Putting the kit together

You now know every part. Real devices are just these parts combined with a little logic: read something, decide, react. Here are four builds that use what you have learned. Each one reuses code from earlier topics.

Project 1
Room monitor

Reads temperature, humidity and light, and warns when the room gets too hot. Combines the DHT11, the LDR, an LED and a buzzer.

Arduino
#include <DHT.h>
DHT dht(2, DHT11);
int ldr = A0, led = 6, buzzer = 8;
float limit = 30.0;

void setup() {
  Serial.begin(9600); dht.begin();
  pinMode(led, OUTPUT); pinMode(buzzer, OUTPUT);
}
void loop() {
  float t = dht.readTemperature();
  int light = analogRead(ldr);
  Serial.print(t); Serial.print(" C   light ");
  Serial.println(light);

  if (t > limit) {
    digitalWrite(led, HIGH); tone(buzzer, 1200);
  } else {
    digitalWrite(led, LOW); noTone(buzzer);
  }
  delay(1000);
}
Project 2
Security system

The PIR senses a person, the ultrasonic measures how close, the buzzer and LED raise the alarm. Reuse the PIR code from Distance and the HC-SR04 code, and sound the alarm when motion is seen within 50 cm.

Project 3
Smart light

An LDR decides when it is dark, and a relay switches a real lamp on, or an LED for practice. Reuse the night-light code from Sensors and swap the LED for the relay from Modules.

Project 4
Parking sensor

The HC-SR04 measures distance and the buzzer beeps faster as you get closer, exactly like a car. The full code is in the Distance topic. Mount it on a wall and test it with your hand.

Build it
Pick one build, wire it on the breadboard, and get it working. Then change one thing: a new threshold, an extra sensor, or an output of your own.
That step, changing it yourself, is where you stop following tutorials and start designing.
Debug
The Serial Monitor is your eyes

You cannot see inside the chip, but you can ask it to report. Serial.print shows values live while the sketch runs. It is the single most useful tool for finding out why a project misbehaves.

Arduino
void setup() { Serial.begin(9600); }
void loop() {
  Serial.print("Sensor: ");
  Serial.println(analogRead(A0));
  delay(300);
}
Open the Serial Monitor from the top right of the IDE and set its baud to 9600 to match Serial.begin. Random symbols mean the baud does not match.
Debug
When nothing works, go in order
1
Is the board powered and its light on?
2
Right board and port selected in the Tools menu?
3
Did the upload finish, not just compile?
4
Does every wire match the pin numbers in the code?
5
Is GND connected? Most dead projects are a missing ground.
6
Is the component the right way round? LEDs and chips have a direction.
7
Does the Serial baud match Serial.begin?
Debug
Common mistakes
MistakeWhat you see
LED in backwardsit never lights
No resistor on the LEDbright once, then dead
Missing groundnothing works
Forgot pinModethe pin does nothing
delay() too longthe board seems frozen
Wrong library not installedit will not compile
Practice C
A live C console

Arduino code is C. To drill the language itself, write plain C here and run it on a real compiler. For the full language, see the C Programming course on this site.

C Console
GCC via Wandbox
Ready
Output
Your output will appear here after you run the code.
Where next
After the kit

Once the kit feels easy, the next steps open up fast.

  • Wi-Fi and IoT with the ESP32, which runs the same code and can reach the internet.
  • Design your own PCB instead of a breadboard.
  • A bigger project of your own, which is the best way to learn.
You have now met every part in the kit. From here, you are not following tutorials, you are building.