Explore a diverse range of innovative projects built with Arduino, Raspberry Pi, and other exciting technologies.
A smart car that uses an ultrasonic sensor to detect and avoid obstacles in its path.
Control home appliances using a mobile phone via Bluetooth and Arduino relay system.
Monitor real-time temperature, humidity, and pressure data with sensor feedback and LCD display.
Automatically opens its lid when someone approaches—perfect for hygiene and accessibility.
The **Obstacle Avoiding Robot** is an exciting beginner-level robotics project that demonstrates autonomous navigation. This robot uses an **ultrasonic sensor (HC-SR04)** to detect objects in its path and an **Arduino Uno** to process the sensor data, commanding its **DC motors** to change direction and avoid collisions. It's a fantastic introduction to sensors, motor control, and basic robotics programming.
The HC-SR04 ultrasonic sensor constantly emits ultrasonic sound waves and measures the time it takes for the echo to return. The Arduino uses this time to calculate the distance to any object in front of the robot. If an obstacle is detected within a predefined range (e.g., 20 cm), the Arduino stops the robot, looks left and right to find a clear path, and then moves in the direction with the greatest distance.
#define trigPin 9
#define echoPin 8
#define motorPin1_L 2 // Left Motor IN1
#define motorPin2_L 3 // Left Motor IN2
#define motorPin1_R 4 // Right Motor IN1
#define motorPin2_R 5 // Right Motor IN2
#define enableL 6 // Left Motor Enable (PWM)
#define enableR 7 // Right Motor Enable (PWM)
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(motorPin1_L, OUTPUT);
pinMode(motorPin2_L, OUTPUT);
pinMode(motorPin1_R, OUTPUT);
pinMode(motorPin2_R, OUTPUT);
pinMode(enableL, OUTPUT);
pinMode(enableR, OUTPUT);
Serial.begin(9600);
// Set initial speed
analogWrite(enableL, 150); // Adjust speed (0-255)
analogWrite(enableR, 150);
}
void loop() {
distance = calculateDistance();
if (distance <= 20) { // If obstacle is within 20cm
stopRobot();
delay(500);
turnRight(); // Try turning right
delay(700); // Turn for a short duration
distance = calculateDistance();
if (distance <= 20) { // Still an obstacle, try turning left
stopRobot();
delay(500);
turnLeft();
delay(1400); // Turn longer to try another direction
distance = calculateDistance();
if (distance <= 20) { // Still no clear path, turn around
stopRobot();
delay(500);
turnAround();
delay(1000);
}
}
}
moveForward(); // Keep moving forward if no obstacle
}
// Function to calculate distance
int calculateDistance() {
// ... (Full function sends pulse and reads echo, returns distance in cm)
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
return distance;
}
// Motor control functions (moveForward, stopRobot, turnLeft, turnRight, turnAround)
void moveForward() {
digitalWrite(motorPin1_L, HIGH); digitalWrite(motorPin2_L, LOW);
digitalWrite(motorPin1_R, HIGH); digitalWrite(motorPin2_R, LOW);
}
void stopRobot() {
digitalWrite(motorPin1_L, LOW); digitalWrite(motorPin2_L, LOW);
digitalWrite(motorPin1_R, LOW); digitalWrite(motorPin2_R, LOW);
}
void turnRight() {
digitalWrite(motorPin1_L, HIGH); digitalWrite(motorPin2_L, LOW);
digitalWrite(motorPin1_R, LOW); digitalWrite(motorPin2_R, HIGH); // Right motor backward
}
void turnLeft() {
digitalWrite(motorPin1_L, LOW); digitalWrite(motorPin2_L, HIGH); // Left motor backward
digitalWrite(motorPin1_R, HIGH); digitalWrite(motorPin2_R, LOW);
}
void turnAround() {
digitalWrite(motorPin1_L, HIGH); digitalWrite(motorPin2_L, LOW);
digitalWrite(motorPin1_R, LOW); digitalWrite(motorPin2_R, HIGH);
}
Simplified Arduino code for obstacle avoidance logic.
This project lays the groundwork for more advanced autonomous robots, robotic vacuum cleaners, and automated guided vehicles (AGVs) in industrial settings.
This **Home Automation System** allows you to control your household appliances (like lights, fans, etc.) remotely using your smartphone via **Bluetooth**. Built with **Arduino**, it's a practical and cost-effective way to introduce smart features into your living space, enhancing convenience and energy efficiency.
The Arduino receives commands wirelessly from your smartphone via the HC-05 Bluetooth module. Based on the received commands (e.g., a character like 'A' for light on, 'a' for light off), the Arduino then triggers the appropriate relay. Relays act as electrically operated switches, safely controlling the higher voltage AC current flowing to your appliances.
char command; // Variable to store incoming command
void setup() {
Serial.begin(9600); // Initialize serial communication with Bluetooth module
pinMode(2, OUTPUT); // Pin for Relay 1 (e.g., Light)
pinMode(3, OUTPUT); // Pin for Relay 2 (e.g., Fan)
// Set initial state (all off)
digitalWrite(2, HIGH); // Relays are often active LOW
digitalWrite(3, HIGH);
}
void loop() {
if (Serial.available() > 0) { // Check if data is available from Bluetooth
command = Serial.read(); // Read the incoming character
switch (command) {
case 'A': // Command to turn Light ON
digitalWrite(2, LOW); // Activate Relay 1
Serial.println("Light ON");
break;
case 'a': // Command to turn Light OFF
digitalWrite(2, HIGH); // Deactivate Relay 1
Serial.println("Light OFF");
break;
case 'B': // Command to turn Fan ON
digitalWrite(3, LOW); // Activate Relay 2
Serial.println("Fan ON");
break;
case 'b': // Command to turn Fan OFF
digitalWrite(3, HIGH); // Deactivate Relay 2
Serial.println("Fan OFF");
break;
default:
// Optional: Handle unknown commands
break;
}
}
}
Core Arduino code for Bluetooth-controlled relays.
Beyond basic home appliance control, this project can be expanded into more complex smart home systems, integrating with other sensors (e.g., light sensors to turn on lights automatically), and even moving towards Wi-Fi based IoT solutions.
Build your own compact **Weather Station** using Arduino! This project allows you to monitor real-time environmental data such as **temperature, humidity, and atmospheric pressure**. The readings are displayed on a **16x2 LCD** for easy viewing, making it a great educational project for understanding sensor data acquisition and display.
The Arduino communicates with the DHT11/DHT22 sensor to get temperature and humidity readings. Simultaneously, it interfaces with the BMP180 sensor via the I2C protocol to obtain atmospheric pressure and another temperature reading. All this collected data is then formatted and displayed on the 16x2 LCD screen, updating periodically.
#include <Wire.h>
#include <Adafruit_Sensor.h> // Required for DHT sensor library
#include <DHT.h> // DHT sensor library
#include <Adafruit_BMP085.h> // BMP180/BMP085 sensor library
#include <LiquidCrystal_I2C.h> // I2C LCD library
// Define DHT sensor type and pin
#define DHTPIN 7
#define DHTTYPE DHT11 // Or DHT22
DHT dht(DHTPIN, DHTTYPE);
// Initialize BMP sensor
Adafruit_BMP085 bmp;
// Initialize LCD with I2C address and dimensions
LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust address if needed (0x3F or 0x27)
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
dht.begin();
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
while(1);
}
Serial.println("BMP085 sensor found!");
lcd.print("Weather Station");
lcd.setCursor(0,1);
lcd.print("Initializing...");
delay(2000);
}
void loop() {
float h = dht.readHumidity();
float t_dht = dht.readTemperature(); // Temperature from DHT
if (isnan(h) || isnan(t_dht)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Get temperature and pressure from BMP180
float t_bmp = bmp.readTemperature(); // Temperature from BMP180
float p = bmp.readPressure();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(t_dht); // Or t_bmp, depends on preference
lcd.print((char)223); // Degree symbol
lcd.print("C Hum:");
lcd.print(h);
lcd.print("%");
lcd.setCursor(0,1);
lcd.print("Pressure:");
lcd.print(p / 100.0F); // Convert Pa to hPa/mbar
lcd.print("hPa");
delay(5000); // Update every 5 seconds
}
Core Arduino code for reading sensors and displaying on LCD.
This project is a perfect foundation for home environmental monitoring, smart garden systems, or even building a small personal weather station that logs data to a computer or cloud platform (with additional modules like ESP8266 for Wi-Fi).
The **Smart Dustbin** is an innovative hygiene-focused project that automatically opens its lid when it detects a hand approaching. This touchless operation promotes better sanitation and reduces the spread of germs, making it ideal for public spaces, kitchens, and labs. It's a simple yet effective application of sensors and actuators with **Arduino**.
The ultrasonic sensor continuously measures the distance to objects in front of it. When a hand (or any object) comes within a set range (e.g., 15-20 cm), the Arduino receives this information. It then sends a signal to the servo motor, which rotates to open the dustbin lid. After a short delay (allowing the user to deposit waste), the servo rotates back, closing the lid.
#include <Servo.h> // Include the Servo library
#define trigPin 9 // Ultrasonic sensor Trig pin
#define echoPin 8 // Ultrasonic sensor Echo pin
#define servoPin 3 // Servo motor signal pin (PWM pin recommended)
Servo myServo; // Create a servo object
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
myServo.attach(servoPin); // Attach the servo to its pin
myServo.write(0); // Ensure lid starts closed (adjust angle if needed for your setup)
Serial.begin(9600);
}
void loop() {
// Clear the trigPin by setting it LOW for 2 microseconds
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Set the trigPin HIGH for 10 microseconds to send pulse
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculate the distance: Speed of sound = 0.034 cm/microsecond
// Distance = (Travel Time * Speed of Sound) / 2 (for round trip)
distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
if (distance <= 20) { // If object is within 20 cm
myServo.write(90); // Open the lid (adjust angle for your setup)
delay(2000); // Keep lid open for 2 seconds
} else {
myServo.write(0); // Close the lid
}
delay(100); // Small delay before next reading
}
Core Arduino code for the Smart Dustbin.
This concept can be extended to automated dispensers, smart pet feeders, or even sensor-activated entry systems, demonstrating the versatility of simple proximity detection and motion control.