Arduino STEM Projects Complete Documentation
1. Line Following Car
Components Required:
• Arduino Uno / Nano
• IR Sensor Module (2 or 3)
• L298N Motor Driver Module
• 2 DC Geared Motors
• Robot Chassis with Wheels + Caster Wheel
• 7.4V Li-ion Battery
• Jumper Wires
• On/Off Switch
Theory:
A Line Following Robot follows a black line using IR sensors. White surfaces reflect infrared
light while black absorbs it. Based on sensor readings, Arduino controls motors through the
L298N motor driver.
Arduino Code:
// Line Following Robot
int leftSensor = 2;
int rightSensor = 3;
int motorA1 = 5;
int motorA2 = 6;
int motorB1 = 9;
int motorB2 = 10;
void setup() {
pinMode(leftSensor, INPUT);
pinMode(rightSensor, INPUT);
pinMode(motorA1, OUTPUT);
pinMode(motorA2, OUTPUT);
pinMode(motorB1, OUTPUT);
pinMode(motorB2, OUTPUT);
}
void loop() {
int left = digitalRead(leftSensor);
int right = digitalRead(rightSensor);
if(left == 0 && right == 0) {
digitalWrite(motorA1, HIGH);
digitalWrite(motorA2, LOW);
digitalWrite(motorB1, HIGH);
digitalWrite(motorB2, LOW);
}
else if(left == 0 && right == 1) {
digitalWrite(motorA1, LOW);
digitalWrite(motorA2, LOW);
digitalWrite(motorB1, HIGH);
digitalWrite(motorB2, LOW);
}
else if(left == 1 && right == 0) {
digitalWrite(motorA1, HIGH);
digitalWrite(motorA2, LOW);
digitalWrite(motorB1, LOW);
digitalWrite(motorB2, LOW);
}
else {
digitalWrite(motorA1, LOW);
digitalWrite(motorA2, LOW);
digitalWrite(motorB1, LOW);
digitalWrite(motorB2, LOW);
}
}
2. Smart Dustbin
Components Required:
• Arduino Uno / Nano
• Ultrasonic Sensor (HC-SR04)
• Servo Motor (SG90)
• Dustbin with Lid
• Breadboard
• Jumper Wires
• 5V Power Supply
Theory:
Smart Dustbin uses an ultrasonic sensor to measure distance using sound waves. When a
hand is detected within 15 cm, Arduino rotates the servo motor to open the lid
automatically.
Arduino Code:
#include <Servo.h>
Servo myServo;
int trigPin = 9;
int echoPin = 10;
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
[Link](6);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
if(distance < 15) {
[Link](90);
delay(3000);
[Link](0);
}
}
3. Smart Plant Watering System
Components Required:
• Arduino Uno / Nano
• Soil Moisture Sensor
• Relay Module
• Mini Water Pump
• Water Pipe
• External Power Supply
• Jumper Wires
Theory:
The soil moisture sensor detects water content in soil. If soil is dry, Arduino activates relay
which turns ON the water pump. When moisture becomes sufficient, pump turns OFF
automatically.
Arduino Code:
int moisturePin = A0;
int relayPin = 7;
int moistureValue;
void setup() {
pinMode(relayPin, OUTPUT);
[Link](9600);
}
void loop() {
moistureValue = analogRead(moisturePin);
if(moistureValue > 600) {
digitalWrite(relayPin, LOW);
} else {
digitalWrite(relayPin, HIGH);
}
delay(1000);
}
4. LCD Token Display System
Components Required:
• Arduino Uno / Nano
• 16x2 LCD Display (I2C)
• Push Buttons (Next, Reset)
• Buzzer
• Breadboard
• Jumper Wires
• 5V Power Supply
Theory:
This project displays visitor token numbers outside the principal's office. Pressing the Next
button increases the token number and buzzer gives alert sound. Reset button sets token
back to 1.
Arduino Code:
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int nextButton = 2;
int resetButton = 3;
int buzzer = 8;
int token = 1;
void setup() {
[Link]();
[Link]();
pinMode(nextButton, INPUT);
pinMode(resetButton, INPUT);
pinMode(buzzer, OUTPUT);
[Link]("Token: 1");
}
void loop() {
if(digitalRead(nextButton) == HIGH) {
token++;
[Link]();
[Link]("Token: ");
[Link](token);
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer, LOW);
delay(300);
}
if(digitalRead(resetButton) == HIGH) {
token = 1;
[Link]();
[Link]("Token: 1");
delay(300);
}
}