🎓 Arduino Programming

Arduino Tutorial for Class 6–8

Introduction to Arduino

Arduino is an open-source electronics platform used to build interactive projects. It combines a small programmable computer called a microcontroller with input and output pins.

Easy definition: Arduino is a tiny computer that can sense the world, make decisions, and control things.

The basic idea

Input → Processing → Output

What is Arduino Uno?

Arduino Uno is one of the most popular beginner boards. It is an excellent choice for school-level electronics and programming.

PartPurpose
MicrocontrollerThe brain that runs the program.
Digital pinsRead or control ON/OFF signals.
Analog pinsRead changing sensor values.
5V / 3.3VPower connections for compatible components.
GNDElectrical reference/ground.
USB portConnects Arduino to a computer and uploads programs.
Reset buttonRestarts the running program.

Electronics Basics

Voltage, Current and Resistance

Voltage is the electrical potential that pushes charge. Current is the flow of electric charge. Resistance opposes current.

Water analogy: Voltage is like water pressure, current is like water flow, and resistance is like a narrow pipe that restricts the flow.

What is a circuit?

A circuit is a complete path through which electricity can flow. A simple LED circuit uses a power source, wires, a resistor and an LED.

LED and resistor

An LED is a light-emitting diode. In beginner circuits, use an appropriate current-limiting resistor with an LED. A common starting value is 220Ω or 330Ω.

What is a breadboard?

A breadboard lets you build temporary circuits without soldering. The holes are internally connected in groups, allowing components and jumper wires to share electrical connections.

Arduino Programming

Arduino programs are often called sketches. The two most important functions are setup() and loop().

void setup() {
  // Runs once
}

void loop() {
  // Runs repeatedly
}

First program: Blink

The classic first Arduino experiment is making an LED blink.

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

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);

  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

How it works: Arduino sets the built-in LED as an output, turns it on, waits one second, turns it off, waits one second, and repeats.

pinMode()

pinMode(13, OUTPUT);
pinMode(2, INPUT);

pinMode() tells Arduino whether a pin will be used as an input or output.

digitalWrite()

digitalWrite(13, HIGH);
digitalWrite(13, LOW);

HIGH and LOW are commonly used for digital ON/OFF control.

digitalRead()

int buttonState = digitalRead(2);

Use it to read a digital input such as a push button.

Variables

int ledPin = 13;
int score = 10;
float temperature = 27.5;

A variable is a named storage location for information. Students can think of it as a labelled box.

if / else

if (buttonState == HIGH) {
  digitalWrite(13, HIGH);
} else {
  digitalWrite(13, LOW);
}

An if statement lets Arduino make decisions.

for loop

for (int i = 0; i < 3; i++) {
  digitalWrite(13, HIGH);
  delay(300);
  digitalWrite(13, LOW);
  delay(300);
}

Serial Monitor

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("Hello from Arduino!");
  delay(1000);
}

The Serial Monitor helps students see values and messages from Arduino. It is also an important debugging tool.

Components & Sensors

ComponentWhat students learnExample
LEDDigital outputIndicator light
Push buttonDigital inputSwitch
PotentiometerVariable analog inputBrightness control
LDRLight sensingAutomatic lamp
BuzzerSound outputAlarm
Ultrasonic sensorDistance measurementParking sensor
PIR sensorMotion detectionSecurity alarm
ServoControlled movementAutomatic door
DC motorContinuous rotationRobot

Digital vs Analog

Digital: usually represents states such as HIGH and LOW.

Analog: represents a changing measurement across a range.

Reading an analog sensor

int sensorValue = analogRead(A0);

void setup() {
  Serial.begin(9600);
}

void loop() {
  sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  delay(500);
}

Practical Projects

Project 1 — Traffic Light Class 6

Learn: digital outputs, timing and sequencing.

Use red, yellow and green LEDs to simulate a traffic signal.

Project 2 — Push Button Lamp Class 6

Learn: digital input and output.

Press a button to turn an LED on and release it to turn the LED off.

Project 3 — Electronic Dice Class 6–7

Learn: variables, random numbers, LEDs and buttons.

Project 4 — Automatic Night Lamp Class 7

Learn: analog input, LDR and conditions.

int light = analogRead(A0);

if (light < 400) {
  digitalWrite(13, HIGH);
} else {
  digitalWrite(13, LOW);
}

Project 5 — Security Alarm Class 7

Use a motion sensor to detect movement and activate a buzzer.

Project 6 — Parking Sensor Class 7–8

Use an ultrasonic sensor to measure distance. Make the buzzer beep faster as an object gets closer.

Project 7 — Automatic Door Class 8

Combine a sensor with a servo motor. Detect a person and move the servo to open a miniature door.

Project 8 — Smart Dustbin Class 8

Use an ultrasonic sensor and servo motor to open the lid when a hand approaches.

Project 9 — Obstacle-Avoiding Robot Class 8

Combine an ultrasonic sensor, Arduino, motor driver and two DC motors. The robot detects an obstacle and changes direction.

Class 6 Learning Path

  1. What is Arduino?
  2. Basic electricity and circuits.
  3. LED and resistor.
  4. Breadboard and jumper wires.
  5. Arduino pins.
  6. setup() and loop().
  7. Blinking LED.
  8. Traffic light.
  9. Push button.
  10. Buzzer and mini project.

Class 7 Learning Path

  1. Review digital input/output.
  2. Variables and data types.
  3. if/else.
  4. Analog input.
  5. Potentiometer.
  6. LDR and automatic light.
  7. Serial Monitor.
  8. Temperature or motion sensor.
  9. Ultrasonic distance sensor.
  10. Integrated mini project.

Class 8 Learning Path

  1. Review Arduino programming.
  2. Loops and functions.
  3. Servo motors.
  4. DC motors and motor drivers.
  5. Ultrasonic sensing.
  6. Displays and user interfaces.
  7. Combining sensors and outputs.
  8. Robot fundamentals.
  9. Project design and testing.
  10. Final STEM exhibition project.

Debugging

Students should learn that mistakes are part of engineering.

Remember: If a project does not work, don't immediately rebuild everything. Change one thing at a time and test it.

Hardware checklist

Software checklist

Arduino Safety

Practice Quiz

  1. What is the brain of an Arduino board called?
  2. What is the difference between an input and an output?
  3. What does setup() do?
  4. What does loop() do?
  5. What is the purpose of a resistor with an LED?
  6. What is the difference between digital and analog input?
  7. What does digitalRead() do?
  8. What does analogRead() do?
  9. Why is Serial Monitor useful?
  10. Design a project using one sensor and one output.

Final Challenge

Think like an engineer:
Choose a real-world problem. Decide what your Arduino needs to sense. Decide what action it should take. Draw the circuit, write the program, test it, find mistakes, and improve your design.

Example: “I want to make a plant-care system.”

Soil moisture sensor
        ↓
      Arduino
        ↓
If soil is dry → activate pump
If soil is wet → keep pump OFF