Arduino TOP 75+ Projects Code & Circuits
Arduino TOP 75+ Projects Code & Circuits
Projects !
contact us
@mr_circuits007
[email protected]
"Arduino TOP 75+ Projects: Code & Circuits"
Description:
Dive into the world of Arduino with "Arduino TOP 75+ Projects: Code & Circuits," your
ultimate guide to mastering the art of electronics through hands-on projects. Whether
you're a beginner eager to learn or an experienced enthusiast looking for fresh
inspiration, this comprehensive eBook has something for everyone.
Unlock the potential of Arduino with this curated collection of 75+ projects,
meticulously designed to cover a wide range of applications and skill levels. From basic
tutorials to advanced innovations, each project is accompanied by detailed
instructions, clear circuit diagrams, and ready-to-use code snippets, ensuring a smooth
and rewarding learning experience.
No matter your background or experience level, this eBook serves as your companion
on your Arduino journey. Beginners will appreciate the step-by-step instructions and
gentle introduction to electronics and programming concepts, while seasoned makers
will find plenty of challenging projects to sink their teeth into. With clear explanations
and troubleshooting tips, you'll overcome obstacles with ease and emerge as a
proficient Arduino enthusiast.
What sets "Arduino TOP 75+ Projects: Code & Circuits" apart is its focus on both theory
and practice. Each project is accompanied by concise explanations of the underlying
principles, helping you understand not just how to build it, but why it works. Whether
you're interested in learning about sensors, actuators, communication protocols, or
power management, you'll find everything you need to know within these pages.
In addition to being a valuable learning resource, this eBook also serves as a source of
inspiration for your own projects. Use the provided code as a starting point and
customize it to suit your needs. Experiment with different components, sensors, and
algorithms to create unique solutions tailored to your specific requirements. With
Arduino, the only limit is your imagination!
So why wait? Join the millions of makers around the world who have embraced Arduino
as their go-to platform for creativity and innovation. Whether you're a hobbyist, a
student, an educator, or a professional, "Arduino TOP 75+ Projects: Code & Circuits" is
your passport to a world of endless possibilities. Get ready to embark on an exciting
journey of discovery and empowerment with Arduino!
Projects List & Name
1. Led Blink
2. BLDC Motor Speed Control
3. Flame Sensor Projects
4. Flame Sensor Projects
5. IR Recevier Projects
6. Joystick Servo control
7. L298N Motor Driver
8. LCD_Display
9. LDR Sensor
10. MLX90614 With Buzzer
11. MLX90614 With Buzzer LCD
12. PIR Sensor Projects
13. Water Sensor
14. Sound Sensor
15. Stepper Motor
16. Tilt Sensor
17. Ultrasonic Sensor And Buzzer
18. Vibration Sensor
19. Automatic Plant Watering System
20.Balanced Robot
21. Fingerprint Lock System
22.Human Following Robot
23.IR Remote Car
24.Line Following Robot
25.WiFi Car
26.Bluetooth control car
27.Digital clock
28.Distance Measurement using Ultrasonic sensor
29.Object Avoding Robot
30.RFID Door Lock System
31. Smart Dustbin
32.Soil Moisture Sensor
33.Arduino Car Parking System
34.Arduino Voice Control Home Automation
35. Arduino Text Scrolling Message Display
36.Arduino Digital Weight Scale
37.Arduino Touch Sensor
38.Arduino ECG Heart Rate Monitor AD8232
39.Arduino Keypad Solenoid Lock
40.Arduino Voltmeter OLED Display
41. Arduino Rotary Encoder controlled LEDs
42.Arduino OLED Stopwatch
43.Arduino BT Door Lock Control
44.Arduino LCD Notice Board
45. Arduino MPU6050 Digital Spirit Level Measuring Device
46.Arduino Secret Knock Pattern Door Lock
47.Arduino Home Automation using Bluetooth
48.Arduino Shake DICE OLED Display
49.Arduino Timer Control Relay
50.Arduino control Servo with MPU6050
51. Arduino RFID Door Lock System with LCD Display + 25 MORE PROJECTS
Led Blink
Components :
1. Arduino Uno
2. 5MM Led
3. 220 Ohm Resistor
4. Breadboard
Circuit Diagram :
Code :
// the setup function runs once when you press reset or power the
board
void setup()
{
// initialize digital pin D2 as an output.
pinMode(2, OUTPUT);
Serial.begin(9600);
}
Serial.println("Mr_circuits007");
}
BLDC Motor Speed Control
Components :
1. Arduino Uno
2. 30A ESC
3. BLDC Motor
4. Jaystick
Circuit Diagram :
Code :
#include<Servo.h>
#define ESC_PIN 2
Servo esc;
void setup()
{
esc.attach(ESC_PIN, 1000, 2000);
esc.write(0);
delay(2000);
}
void loop()
{
int joystickValue = analogRead(A0);
joystickValue = constrain(joystickValue, 550, 1023);
int mmotorSpeed = map(joystickValue, 550, 1023, 0, 180);
esc.write(mmotorSpeed);
}
Flame Sensor Projects
Components :
1. Arduino Uno
2. Relay Module
3. Buzzer
4. Flame Sensor
5. DC Motor
Circuit Diagram :
Code :
#define SENSOR_PIN 2
#define BUZZER_PIN 3
#define RELAY_PIN 4
#define SPRINKLER_START_DELAY 5000 //5 seconds
#define SPRINKLER_ON_TIME 3000 //3 seconds Sprinkler on time
void setup()
{
pinMode(RELAY_PIN, OUTPUT);
pinMode(SENSOR_PIN, INPUT);
}
void loop()
{
//If there is fire then the sensor value will be LOW else the value will be HIGH
int sensorValue = digitalRead(SENSOR_PIN);
//There is fire
if (sensorValue == LOW)
{
analogWrite(BUZZER_PIN, 50);
Components :
1. Arduino Uno
2. Smoke Sensor
3. Buzzer
Circuit Diagram :
Code :
#define BUZZER_PIN 3
void setup()
{
pinMode(BUZZER_PIN, OUTPUT);
//Serial.begin(9600);
}
void loop()
{
int sensorValue = analogRead(A0);
//Serial.println(sensorValue);
if (sensorValue > 200)
{
analogWrite(BUZZER_PIN, 50);
}
else
{
analogWrite(BUZZER_PIN, 0);
}
delay(1000);
}
IR Recevier Projects
Components :
1. Arduino Uno
2. IR Recevier
3. Relay Module
Circuit Diagram :
Components :
1. Arduino Uno
2. Servo Motor
3. Jaystick
Circuit Diagram :
Main Code :
#include<Servo.h>
#define SERVO_PIN 2
Servo myServo;
void setup()
{
myServo.attach(SERVO_PIN);
}
void loop()
{
int joystickValue = analogRead(A0);
int output = map(joystickValue, 0, 1023, 0, 180);
myServo.write(output);
delay(10);
}
L298N Motor Driver
Components :
1. Arduino Uno
2. L298d Motor Driver
3. Jaystick
4. DC Motor
Circuit Diagram :
Main Code :
int enableAPin = 3;
int in1Pin = 4;
int in2Pin = 5;
void setup()
{
pinMode(enableAPin, OUTPUT);
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
}
void loop()
{
int motorPWMSpeed = 0;
int joystickValue = analogRead(A0);
Main Code :
#include <LiquidCrystal.h>
const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup()
{
lcd.begin(16, 2);
lcd.clear();
void loop()
{
// Turn off the display:
lcd.noDisplay();
delay(1000);
// Turn on the display:
lcd.display();
delay(1000);
}
LDR Sensor
Components :
1. Arduino Uno
2. LDR
3. Relay Module
Circuit Diagram :
Main Code :
#define SENSOR_PIN 2
#define RELAY_PIN 3
void setup()
{
pinMode(RELAY_PIN, OUTPUT);
pinMode(SENSOR_PIN, INPUT);
//Serial.begin(9600);
}
void loop()
{
Components :
1. Arduino Uno
2. MLX90614 Sensor
3. Ultrasonic Sensor
4. Buzzer
Circuit Diagram :
Main Code :
Main Code :
#include <NewPing.h>
#include <Adafruit_MLX90614.h>
#define BUZZER_PIN 5
#define CUT_OFF_TEMPERATURE 30 //This is temperature in degreeC
#define DISTANCE_TO_CHECK 10 //This is in cm
NewPing ultrasonicSensor(2,3,400);
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
void setup()
{
analogWrite(BUZZER_PIN, 0);
mlx.begin();
}
void tempHighTone()
{
for (int i = 0; i < 10; i++)
{
analogWrite(BUZZER_PIN,100);
delay(100);
analogWrite(BUZZER_PIN,0);
delay(100);
}
}
void tempOkTone()
{
analogWrite(BUZZER_PIN, 100);
delay(2000);
analogWrite(BUZZER_PIN, 0);
}
void loop()
{
int distance = ultrasonicSensor.ping_cm();
if (distance > 0 && distance < DISTANCE_TO_CHECK)
{
delay(2000);
float temperature = mlx.readObjectTempC();
distance = ultrasonicSensor.ping_cm();
if (distance > 0 && distance < DISTANCE_TO_CHECK && temperature <=
CUT_OFF_TEMPERATURE)
{
tempOkTone();
delay(2000);
}
else if ( !(distance > 0 && distance < DISTANCE_TO_CHECK))
{
}
else
{
tempHighTone();
delay(2000);
}
}
}
MLX90614 With Buzzer LCD
Components :
1. Arduino Uno
2. 16x2 Display
3. MLX90614 Sensor
4. Ultrasonic Sensor
5. Buzzer
6. 220 ohm
7. 10k Presat
Circuit Diagram :
Main Code :
Main Code :
#include <NewPing.h>
#include <Adafruit_MLX90614.h>
#include <LiquidCrystal.h>
#define BUZZER_PIN 5
#define CUT_OFF_TEMPERATURE 25 //This is temperature in degreeC
#define DISTANCE_TO_CHECK 10 //This is in cm
void setup()
{
lcd.begin(16, 2);
lcd.clear();
analogWrite(BUZZER_PIN, 0);
mlx.begin();
}
void tempHighTone()
{
for (int i = 0; i < 10; i++)
{
analogWrite(BUZZER_PIN,100);
delay(100);
analogWrite(BUZZER_PIN,0);
delay(100);
}
}
void tempOkTone()
{
analogWrite(BUZZER_PIN, 100);
delay(2000);
analogWrite(BUZZER_PIN, 0);
}
void loop()
{
String displayString;
lcd.setCursor(0, 0);
lcd.print("Check Temp");
Components :
1. Arduino Uno
2. PIR Sensor
3. Relay Module
Circuit Diagram :
Main Code :
#define SENSOR_PIN 2
#define RELAY_PIN 3
void setup()
{
pinMode(RELAY_PIN, OUTPUT);
pinMode(SENSOR_PIN, INPUT);
}
void loop()
{
int sensorValue = digitalRead(SENSOR_PIN);
if (sensorValue == HIGH)
{
digitalWrite(RELAY_PIN, LOW);
}
else
{
digitalWrite(RELAY_PIN, HIGH);
}
}
Water Sensor
Components :
1. Arduino Uno
2. Water Sensor
3. Buzzer
Circuit Diagram :
Main Code :
#define BUZZER_PIN 3
void setup()
{
pinMode(BUZZER_PIN, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
if (sensorValue < 1000)
{
analogWrite(BUZZER_PIN, 50);
}
else
{
analogWrite(BUZZER_PIN, 0);
}
delay(1000);
}
Sound Sensor
Components :
1. Arduino Uno
2. Sound Sensor
3. Relay Module
Circuit Diagram :
Main Code :
#define SENSOR_PIN 2
#define RELAY_PIN 3
void setup()
{
pinMode(SENSOR_PIN , INPUT);
pinMode(RELAY_PIN, OUTPUT);
void loop()
{
int currentValue = digitalRead(SENSOR_PIN);
if (previousValue == HIGH && currentValue == LOW)
{
if (clapCount == 1 && millis() - previousTime >= 500)
{
clapCount = 0;
}
if (clapCount == 0)
{
previousTime = millis();
}
clapCount++;
if (clapCount == 2)
{
relayOutPut = !relayOutPut;
digitalWrite(RELAY_PIN, relayOutPut);
clapCount = 0;
}
delay(200);
}
previousValue = currentValue;
}
Stepper Motor
Components :
1. Arduino Uno
2. Stepper Motor
3. Stepper Motor Driver
4. 1k Pot
Circuit Diagram :
Main Code :
#include <AccelStepper.h>
void setup()
{
stepper.setMaxSpeed(4000);
}
void loop()
{
int potValue = analogRead(A0);
if (potValue < 100 ) potValue = 0;
int stepperMotorSpeed = map(potValue, 0, 1023, 0, 4000);
stepper.setSpeed(stepperMotorSpeed);
stepper.runSpeed();
}
Tilt Sensor
Components :
1. Arduino Uno
2. Tilt Sensor
3. 16x2 Display
4. 5MM Led
5. 10K Pot
6. Breadboard
Circuit Diagram :
Main Code :
#include <LiquidCrystal.h>
#define SENSOR_PIN 2
#define LED_PIN 3
const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup()
{
pinMode(LED_PIN, OUTPUT);
lcd.begin(16, 2);
lcd.clear();
void loop()
{
lcd.setCursor(0, 0); //first column, First row
lcd.clear();
if (digitalRead(SENSOR_PIN) == LOW)
{
lcd.print("Tilt Detected");
digitalWrite(LED_PIN, HIGH);
}
else
{
lcd.print("Not tilted");
digitalWrite(LED_PIN, LOW);
}
delay(500);
}
Ultrasonic Sensor And Buzzer
Components :
1. Arduino Uno
2. Ultrasonic Sensor
3. Buzzer
Circuit Diagram :
Main Code :
#include <NewPing.h>
#define BUZZER_PIN 3
NewPing mySensor(11,12,400);
void setup()
{
pinMode(BUZZER_PIN, OUTPUT);
}
void loop()
{
int distance = mySensor.ping_cm();
if (distance > 0 && distance < 50)
{
analogWrite(BUZZER_PIN, 50);
}
else
{
analogWrite(BUZZER_PIN, 0);
}
delay(50);
}
Vibration Sensor
Components :
1. Arduino Uno
2. Vibration Sensor
3. Buzzer
Circuit Diagram :
Main Code :
#define SENSOR_PIN 2
#define BUZZER_PIN 3
void setup()
{
pinMode(SENSOR_PIN, INPUT);
//Serial.begin(9600);
}
void loop()
{
//If there is no vibration then the sensor value will be 0 else the value will be 1
int sensorValue = digitalRead(SENSOR_PIN);
//Serial.println(sensorValue);
//There is fire
if (sensorValue == LOW)
{
analogWrite(BUZZER_PIN, 0);
}
else
{
//If vibration then turn on the buzzer
analogWrite(BUZZER_PIN, 50);
}
//You can add delay between reading
delay(100);
}
Automatic Plant Watering System
Components :
1. Arduino Uno
2. Soil Sensor
3. 4Channel Realy Module
4. 4x DC Water Pump
Circuit Diagram :
Main Code :
Main Code :
#define SENSOR_READ_DELAY 86400000
#define FULL_MOISTURE_READING 290
#define NO_MOISTURE_READING 595
#define CUT_OFF_MOISTURE_PERCENATGE 50
#define PUMP1_WATERING_TIME 2000
#define PUMP2_WATERING_TIME 2000
#define PUMP3_WATERING_TIME 2000
#define PUMP4_WATERING_TIME 2000
int pumpPin1=2;
int pumpPin2=3;
int pumpPin3=4;
int pumpPin4=5;
int inputSensorPin1=A0;
int inputSensorPin2=A1;
int inputSensorPin3=A2;
int inputSensorPin4=A3;
void setup()
{
// put your setup code here, to run once:
pinMode(pumpPin1,OUTPUT);
pinMode(pumpPin2,OUTPUT);
pinMode(pumpPin3,OUTPUT);
pinMode(pumpPin4,OUTPUT);
digitalWrite(pumpPin1,HIGH);
digitalWrite(pumpPin2,HIGH);
digitalWrite(pumpPin3,HIGH);
digitalWrite(pumpPin4,HIGH);
}
void loop()
{
// put your main code here, to run repeatedly:
int inputSensorPin1Value = analogRead(inputSensorPin1);
getMoisturePercentageAndWaterIt(inputSensorPin1Value, pumpPin1,
PUMP1_WATERING_TIME);
delay(SENSOR_READ_DELAY);
}
Balanced Robot
Components :
1. Arduino Nano
2. L298d Motor Driver
3. MPU6050
4. DC Motor
Circuit Diagram :
Main Code :
Main Code :
//#define PRINT_DEBUG_BUILD //This is to print the mpu data on serial monitor to debug
//PID library
#include <PID_v1.h>
// orientation/motion vars
Quaternion q; // [w, x, y, z] quaternion container
VectorFloat gravity; // [x, y, z] gravity vector
float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector
VectorInt16 gy; // [x, y, z] gyro sensor measurements
volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high
void dmpDataReady() {
mpuInterrupt = true;
}
//The pitch angle given by MPU6050 when robot is vertical and MPU6050 is horizontal is 0 in ideal case.
//However in real case its slightly off and we need add some correction to keep robot vertical.
//This is the angle correction to keep our robot stand vertically. Sometimes robot moves in one direction so we need to adjust this.
#define SETPOINT_PITCH_ANGLE_OFFSET -2.2
double setpointYawRate = 0;
double yawGyroRate = 0;
double yawPIDOutput = 0;
#define PID_PITCH_KP 10
#define PID_PITCH_KI 80
#define PID_PITCH_KD .8
int enableMotor1=9;
int motor1Pin1=5;
int motor1Pin2=6;
int motor2Pin1=7;
int motor2Pin2=8;
int enableMotor2=10;
void setupPID()
{
pitchPID.SetOutputLimits(PID_MIN_LIMIT, PID_MAX_LIMIT);
pitchPID.SetMode(AUTOMATIC);
pitchPID.SetSampleTime(PID_SAMPLE_TIME_IN_MILLI);
yawPID.SetOutputLimits(PID_MIN_LIMIT, PID_MAX_LIMIT);
yawPID.SetMode(AUTOMATIC);
yawPID.SetSampleTime(PID_SAMPLE_TIME_IN_MILLI);
void setupMotors()
{
pinMode(enableMotor1,OUTPUT);
pinMode(motor1Pin1,OUTPUT);
pinMode(motor1Pin2,OUTPUT);
pinMode(enableMotor2,OUTPUT);
pinMode(motor2Pin1,OUTPUT);
pinMode(motor2Pin2,OUTPUT);
rotateMotor(0,0);
}
void setupMPU()
{
mpu.initialize();
pinMode(INTERRUPT_PIN, INPUT);
devStatus = mpu.dmpInitialize();
// supply your own gyro offsets here, scaled for min sensitivity
// X Accel Y Accel Z Accel X Gyro Y Gyro Z Gyro
//OFFSETS -1798, 263, 1124, -261, 26, 32
mpu.setXAccelOffset(-1798);
mpu.setYAccelOffset(263);
mpu.setZAccelOffset(1124);
mpu.setXGyroOffset(-261);
mpu.setYGyroOffset(26);
mpu.setZGyroOffset(32);
// make sure it worked (returns 0 if so)
if (devStatus == 0)
{
// Calibration Time: generate offsets and calibrate our MPU6050
//mpu.CalibrateAccel(6);
//mpu.CalibrateGyro(6);
// turn on the DMP, now that it's ready
mpu.setDMPEnabled(true);
mpuIntStatus = mpu.getIntStatus();
dmpReady = true;
// get expected DMP packet size for later comparison
packetSize = mpu.dmpGetFIFOPacketSize();
}
else
{
// ERROR!
}
}
void setup()
{
//This is to set up motors
setupMotors();
//This is to set up MPU6050 sensor
setupMPU();
//This is to set up PID
setupPID();
}
void loop()
{
// if programming failed, don't try to do anything
if (!dmpReady) return;
pitchPID.Compute(true);
yawPID.Compute(true);
rotateMotor(pitchPIDOutput+yawPIDOutput, pitchPIDOutput-yawPIDOutput);
#ifdef PRINT_DEBUG_BUILD
Serial.println("The gyro before ");
Serial.println(pitchGyroAngle);
Serial.println("The setpoints ");
Serial.println(setpointPitchAngle);
Serial.println("The pid output ");
Serial.println(pitchPIDOutput);
delay(500);
#endif
}
}
if (speed2 < 0)
{
digitalWrite(motor2Pin1,LOW);
digitalWrite(motor2Pin2,HIGH);
}
else if (speed2 >= 0)
{
digitalWrite(motor2Pin1,HIGH);
digitalWrite(motor2Pin2,LOW);
}
analogWrite(enableMotor1,speed1);
analogWrite(enableMotor2,speed2);
}
Fingerprint Lock System
Components :
1. Arduino Uno
2. Fingerprint Sensor
3. Relay Module
4. Electric Door Lock
Circuit Diagram :
Main Code :
Main Code :
#include <Adafruit_Fingerprint.h>
#define RELAY_PIN 4
#define ACCESS_DELAY 3000 // Keep lock unlocked for 3 seconds
void setup()
{
// set the data rate for the sensor serial port
finger.begin(57600);
delay(5);
if (finger.verifyPassword())
{
}
else
{
while (1) { delay(1); }
}
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, HIGH); //Switch off relay initially. Relay is
LOW level triggered relay so we need to write HIGH.
}
void loop()
{
if ( getFingerPrint() != -1)
{
digitalWrite(RELAY_PIN, LOW);
delay(ACCESS_DELAY);
digitalWrite(RELAY_PIN, HIGH);
}
delay(50); //Add some delay before next scan.
}
p = finger.image2Tz();
if (p != FINGERPRINT_OK) return -1;
p = finger.fingerFastSearch();
if (p != FINGERPRINT_OK) return -1;
// found a match!
return finger.fingerID;
}
This Code for FingerPrint Enroll :
#include <Adafruit_Fingerprint.h>
uint8_t id;
void setup()
{
Serial.begin(9600);
while (!Serial);
delay(100);
uint8_t readnumber(void)
{
uint8_t num = 0;
while (num == 0)
{
while (! Serial.available());
num = Serial.parseInt();
}
return num;
}
void loop()
{
Serial.println("\n\nReady to enroll a fingerprint!");
Serial.println("Please type in -1 to delete all the stored finger prints...");
Serial.println("Please type in the ID # (from 1 to 127) you want to save the finger as...");
id = readnumber();
if (id == 0) // ID #0 not allowed, try again!
{
return;
}
if (id == uint8_t(-1))
{
Serial.print("Cleared all finger prints from database");
finger.emptyDatabase();
return;
}
Serial.print("Enrolling ID #");
Serial.println(id);
while (! getFingerprintEnroll() );
}
uint8_t getFingerprintEnroll()
{
int p = -1;
Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id);
while (p != FINGERPRINT_OK)
{
p = finger.getImage();
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
break;
default:
Serial.println("Unknown error");
break;
}
}
// OK success!
p = finger.image2Tz(1);
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("Could not find fingerprint features");
return p;
default:
Serial.println("Unknown error");
return p;
}
Serial.println("Remove finger");
delay(2000);
p = 0;
while (p != FINGERPRINT_NOFINGER)
{
p = finger.getImage();
}
Serial.print("ID "); Serial.println(id);
p = -1;
Serial.println("Place same finger again");
while (p != FINGERPRINT_OK)
{
p = finger.getImage();
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
break;
default:
Serial.println("Unknown error");
break;
}
}
// OK success!
p = finger.image2Tz(2);
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("Could not find fingerprint features");
return p;
default:
Serial.println("Unknown error");
return p;
}
// OK converted!
Serial.print("Creating model for #"); Serial.println(id);
p = finger.createModel();
if (p == FINGERPRINT_OK) {
Serial.println("Prints matched!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_ENROLLMISMATCH) {
Serial.println("Fingerprints did not match");
return p;
} else {
Serial.println("Unknown error");
return p;
}
return true;
}
Human Following Robot
Components :
1. Arduino Uno
2. L298d Motor Driver
3. Ultrasonic Sensor
4. 2x IR Proximity Sensor
5. 4x DC Motor
Circuit Diagram :
Main Code :
Main Code :
#include <NewPing.h>
#define ULTRASONIC_SENSOR_TRIG 11
#define ULTRASONIC_SENSOR_ECHO 12
#define MAX_FORWARD_MOTOR_SPEED 75
#define MAX_MOTOR_TURN_SPEED_ADJUSTMENT 50
#define MIN_DISTANCE 10
#define MAX_DISTANCE 30
#define IR_SENSOR_RIGHT 2
#define IR_SENSOR_LEFT 3
//Right motor
int enableRightMotor=5;
int rightMotorPin1=7;
int rightMotorPin2=8;
//Left motor
int enableLeftMotor=6;
int leftMotorPin1=9;
int leftMotorPin2=10;
void setup()
{
// put your setup code here, to run once:
pinMode(enableRightMotor, OUTPUT);
pinMode(rightMotorPin1, OUTPUT);
pinMode(rightMotorPin2, OUTPUT);
pinMode(enableLeftMotor, OUTPUT);
pinMode(leftMotorPin1, OUTPUT);
pinMode(leftMotorPin2, OUTPUT);
pinMode(IR_SENSOR_RIGHT, INPUT);
pinMode(IR_SENSOR_LEFT, INPUT);
rotateMotor(0,0);
}
void loop()
{
int distance = mySensor.ping_cm();
int rightIRSensorValue = digitalRead(IR_SENSOR_RIGHT);
int leftIRSensorValue = digitalRead(IR_SENSOR_LEFT);
//NOTE: If IR sensor detects the hand then its value will be LOW else the value will be HIGH
//If right sensor detects hand, then turn right. We increase left motor speed and decrease the right motor speed to turn towards right
if (rightIRSensorValue == LOW && leftIRSensorValue == HIGH )
{
rotateMotor(MAX_FORWARD_MOTOR_SPEED - MAX_MOTOR_TURN_SPEED_ADJUSTMENT, MAX_FORWARD_MOTOR_SPEED + MAX_MOTOR_TURN_SPEED_ADJUSTMENT );
}
//If left sensor detects hand, then turn left. We increase right motor speed and decrease the left motor speed to turn towards left
else if (rightIRSensorValue == HIGH && leftIRSensorValue == LOW )
{
rotateMotor(MAX_FORWARD_MOTOR_SPEED + MAX_MOTOR_TURN_SPEED_ADJUSTMENT, MAX_FORWARD_MOTOR_SPEED - MAX_MOTOR_TURN_SPEED_ADJUSTMENT);
}
//If distance is between min and max then go straight
else if (distance >= MIN_DISTANCE && distance <= MAX_DISTANCE)
{
rotateMotor(MAX_FORWARD_MOTOR_SPEED, MAX_FORWARD_MOTOR_SPEED);
}
//stop the motors
else
{
rotateMotor(0, 0);
}
}
if (leftMotorSpeed < 0)
{
digitalWrite(leftMotorPin1,LOW);
digitalWrite(leftMotorPin2,HIGH);
}
else if (leftMotorSpeed > 0)
{
digitalWrite(leftMotorPin1,HIGH);
digitalWrite(leftMotorPin2,LOW);
}
else
{
digitalWrite(leftMotorPin1,LOW);
digitalWrite(leftMotorPin2,LOW);
}
analogWrite(enableRightMotor, abs(rightMotorSpeed));
analogWrite(enableLeftMotor, abs(leftMotorSpeed));
}
IR Remote Car
Components :
1. Arduino Nano
2. L298d Motor Driver
3. IR Recevier
4. DC Motor
Circuit Diagram :
Main Code :
Main Code :
#include <IRremote.h>
//Right motor
int enableRightMotor=5;
int rightMotorPin1=7;
int rightMotorPin2=8;
//Left motor
int enableLeftMotor=6;
int leftMotorPin1=9;
int leftMotorPin2=10;
#define RECV_PIN 2
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
// put your setup code here, to run once:
pinMode(enableRightMotor,OUTPUT);
pinMode(rightMotorPin1,OUTPUT);
pinMode(rightMotorPin2,OUTPUT);
pinMode(enableLeftMotor,OUTPUT);
pinMode(leftMotorPin1,OUTPUT);
pinMode(leftMotorPin2,OUTPUT);
rotateMotor(0,0);
if (leftMotorSpeed < 0)
{
digitalWrite(leftMotorPin1,LOW);
digitalWrite(leftMotorPin2,HIGH);
}
else if (leftMotorSpeed >= 0)
{
digitalWrite(leftMotorPin1,HIGH);
digitalWrite(leftMotorPin2,LOW);
}
analogWrite(enableRightMotor, abs(rightMotorSpeed));
analogWrite(enableLeftMotor, abs(leftMotorSpeed));
}
void loop()
{
if (irrecv.decode(&results))
{
irrecv.resume(); // Receive the next value
//40BD649B FORWARD
//40BD14EB BACKWARD
//40BDA45B LEFT
//40BDE41B RIGHT
//40BDB04F STOP
if (results.value == 0x40BD649B)
{
rotateMotor(MAX_MOTOR_SPEED, MAX_MOTOR_SPEED);
}
else if (results.value == 0x40BD14EB)
{
rotateMotor(-MAX_MOTOR_SPEED, -MAX_MOTOR_SPEED);
}
else if (results.value == 0x40BDA45B)
{
rotateMotor(MAX_MOTOR_SPEED, -MAX_MOTOR_SPEED);
}
else if (results.value == 0x40BDE41B)
{
rotateMotor(-MAX_MOTOR_SPEED, MAX_MOTOR_SPEED);
}
delay(200);
}
else
{
rotateMotor(0, 0);
}
}
Line Following Robot
Components :
1. Arduino Uno
2. L298d Motor Driver
3. 2x IR Proximity Sensor
4. DC Motor
Circuit Diagram :
Main Code :
Main Code :
#define IR_SENSOR_RIGHT 11
#define IR_SENSOR_LEFT 12
#define MOTOR_SPEED 180
//Right motor
int enableRightMotor=6;
int rightMotorPin1=7;
int rightMotorPin2=8;
//Left motor
int enableLeftMotor=5;
int leftMotorPin1=9;
int leftMotorPin2=10;
void setup()
{
//The problem with TT gear motors is that, at very low pwm value it does not even rotate.
//If we increase the PWM value then it rotates faster and our robot is not controlled in that speed and goes out of line.
//For that we need to increase the frequency of analogWrite.
//Below line is important to change the frequency of PWM signal on pin D5 and D6
//Because of this, motor runs in controlled manner (lower speed) at high PWM value.
//This sets frequecny as 7812.5 hz.
TCCR0B = TCCR0B & B11111000 | B00000010 ;
pinMode(enableLeftMotor, OUTPUT);
pinMode(leftMotorPin1, OUTPUT);
pinMode(leftMotorPin2, OUTPUT);
pinMode(IR_SENSOR_RIGHT, INPUT);
pinMode(IR_SENSOR_LEFT, INPUT);
rotateMotor(0,0);
}
void loop()
{
if (rightMotorSpeed < 0)
{
digitalWrite(rightMotorPin1,LOW);
digitalWrite(rightMotorPin2,HIGH);
}
else if (rightMotorSpeed > 0)
{
digitalWrite(rightMotorPin1,HIGH);
digitalWrite(rightMotorPin2,LOW);
}
else
{
digitalWrite(rightMotorPin1,LOW);
digitalWrite(rightMotorPin2,LOW);
}
if (leftMotorSpeed < 0)
{
digitalWrite(leftMotorPin1,LOW);
digitalWrite(leftMotorPin2,HIGH);
}
else if (leftMotorSpeed > 0)
{
digitalWrite(leftMotorPin1,HIGH);
digitalWrite(leftMotorPin2,LOW);
}
else
{
digitalWrite(leftMotorPin1,LOW);
digitalWrite(leftMotorPin2,LOW);
}
analogWrite(enableRightMotor, abs(rightMotorSpeed));
analogWrite(enableLeftMotor, abs(leftMotorSpeed));
}
WiFi Car
Components :
Circuit Diagram :
Main Code :
Main Code :
#include <Arduino.h>
#ifdef ESP32
#include <WiFi.h>
#include <AsyncTCP.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#endif
#include <ESPAsyncWebServer.h>
#define UP 1
#define DOWN 2
#define LEFT 3
#define RIGHT 4
#define UP_LEFT 5
#define UP_RIGHT 6
#define DOWN_LEFT 7
#define DOWN_RIGHT 8
#define TURN_LEFT 9
#define TURN_RIGHT 10
#define STOP 0
#define FRONT_RIGHT_MOTOR 0
#define BACK_RIGHT_MOTOR 1
#define FRONT_LEFT_MOTOR 2
#define BACK_LEFT_MOTOR 3
#define FORWARD 1
#define BACKWARD -1
struct MOTOR_PINS
{
int pinIN1;
int pinIN2;
};
std::vector<MOTOR_PINS> motorPins =
{
{16, 17}, //FRONT_RIGHT_MOTOR
{18, 19}, //BACK_RIGHT_MOTOR
{27, 26}, //FRONT_LEFT_MOTOR
{25, 33}, //BACK_LEFT_MOTOR
};
AsyncWebServer server(80);
AsyncWebSocket ws("/ws");
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}
</style>
</head>
<body class="noselect" align="center" style="background-color:white">
<tr>
<td ontouchstart='onTouchStartAndEnd("3")' ontouchend='onTouchStartAndEnd("0")'><span class="arrows" >⇦</span></td>
<td></td>
<td ontouchstart='onTouchStartAndEnd("4")' ontouchend='onTouchStartAndEnd("0")'><span class="arrows" >⇨</span></td>
</tr>
<tr>
<td ontouchstart='onTouchStartAndEnd("7")' ontouchend='onTouchStartAndEnd("0")'><span class="arrows" >⬋</span></td>
<td ontouchstart='onTouchStartAndEnd("2")' ontouchend='onTouchStartAndEnd("0")'><span class="arrows" >⇩</span></td>
<td ontouchstart='onTouchStartAndEnd("8")' ontouchend='onTouchStartAndEnd("0")'><span class="arrows" >⬊</span></td>
</tr>
<tr>
<td ontouchstart='onTouchStartAndEnd("9")' ontouchend='onTouchStartAndEnd("0")'><span class="circularArrows" >↺</span></td>
<td style="background-color:white;box-shadow:none"></td>
<td ontouchstart='onTouchStartAndEnd("10")' ontouchend='onTouchStartAndEnd("0")'><span class="circularArrows" >↻</span></td>
</tr>
</table>
<script>
var webSocketUrl = "ws:\/\/" + window.location.hostname + "/ws";
var websocket;
function initWebSocket()
{
websocket = new WebSocket(webSocketUrl);
websocket.onopen = function(event){};
websocket.onclose = function(event){setTimeout(initWebSocket, 2000);};
websocket.onmessage = function(event){};
}
function onTouchStartAndEnd(value)
{
websocket.send(value);
}
window.onload = initWebSocket;
document.getElementById("mainTable").addEventListener("touchend", function(event){
event.preventDefault()
});
</script>
</body>
</html>
)HTMLHOMEPAGE";
void rotateMotor(int motorNumber, int motorDirection)
{
if (motorDirection == FORWARD)
{
digitalWrite(motorPins[motorNumber].pinIN1, HIGH);
digitalWrite(motorPins[motorNumber].pinIN2, LOW);
}
else if (motorDirection == BACKWARD)
{
digitalWrite(motorPins[motorNumber].pinIN1, LOW);
digitalWrite(motorPins[motorNumber].pinIN2, HIGH);
}
else
{
digitalWrite(motorPins[motorNumber].pinIN1, LOW);
digitalWrite(motorPins[motorNumber].pinIN2, LOW);
}
}
case UP:
rotateMotor(FRONT_RIGHT_MOTOR, FORWARD);
rotateMotor(BACK_RIGHT_MOTOR, FORWARD);
rotateMotor(FRONT_LEFT_MOTOR, FORWARD);
rotateMotor(BACK_LEFT_MOTOR, FORWARD);
break;
case DOWN:
rotateMotor(FRONT_RIGHT_MOTOR, BACKWARD);
rotateMotor(BACK_RIGHT_MOTOR, BACKWARD);
rotateMotor(FRONT_LEFT_MOTOR, BACKWARD);
rotateMotor(BACK_LEFT_MOTOR, BACKWARD);
break;
case LEFT:
rotateMotor(FRONT_RIGHT_MOTOR, FORWARD);
rotateMotor(BACK_RIGHT_MOTOR, BACKWARD);
rotateMotor(FRONT_LEFT_MOTOR, BACKWARD);
rotateMotor(BACK_LEFT_MOTOR, FORWARD);
break;
case RIGHT:
rotateMotor(FRONT_RIGHT_MOTOR, BACKWARD);
rotateMotor(BACK_RIGHT_MOTOR, FORWARD);
rotateMotor(FRONT_LEFT_MOTOR, FORWARD);
rotateMotor(BACK_LEFT_MOTOR, BACKWARD);
break;
case UP_LEFT:
rotateMotor(FRONT_RIGHT_MOTOR, FORWARD);
rotateMotor(BACK_RIGHT_MOTOR, STOP);
rotateMotor(FRONT_LEFT_MOTOR, STOP);
rotateMotor(BACK_LEFT_MOTOR, FORWARD);
break;
case UP_RIGHT:
rotateMotor(FRONT_RIGHT_MOTOR, STOP);
rotateMotor(BACK_RIGHT_MOTOR, FORWARD);
rotateMotor(FRONT_LEFT_MOTOR, FORWARD);
rotateMotor(BACK_LEFT_MOTOR, STOP);
break;
case DOWN_LEFT:
rotateMotor(FRONT_RIGHT_MOTOR, STOP);
rotateMotor(BACK_RIGHT_MOTOR, BACKWARD);
rotateMotor(FRONT_LEFT_MOTOR, BACKWARD);
rotateMotor(BACK_LEFT_MOTOR, STOP);
break;
case DOWN_RIGHT:
rotateMotor(FRONT_RIGHT_MOTOR, BACKWARD);
rotateMotor(BACK_RIGHT_MOTOR, STOP);
rotateMotor(FRONT_LEFT_MOTOR, STOP);
rotateMotor(BACK_LEFT_MOTOR, BACKWARD);
break;
case TURN_LEFT:
rotateMotor(FRONT_RIGHT_MOTOR, FORWARD);
rotateMotor(BACK_RIGHT_MOTOR, FORWARD);
rotateMotor(FRONT_LEFT_MOTOR, BACKWARD);
rotateMotor(BACK_LEFT_MOTOR, BACKWARD);
break;
case TURN_RIGHT:
rotateMotor(FRONT_RIGHT_MOTOR, BACKWARD);
rotateMotor(BACK_RIGHT_MOTOR, BACKWARD);
rotateMotor(FRONT_LEFT_MOTOR, FORWARD);
rotateMotor(BACK_LEFT_MOTOR, FORWARD);
break;
case STOP:
rotateMotor(FRONT_RIGHT_MOTOR, STOP);
rotateMotor(BACK_RIGHT_MOTOR, STOP);
rotateMotor(FRONT_LEFT_MOTOR, STOP);
rotateMotor(BACK_LEFT_MOTOR, STOP);
break;
default:
rotateMotor(FRONT_RIGHT_MOTOR, STOP);
rotateMotor(BACK_RIGHT_MOTOR, STOP);
rotateMotor(FRONT_LEFT_MOTOR, STOP);
rotateMotor(BACK_LEFT_MOTOR, STOP);
break;
}
}
void setUpPinModes()
{
for (int i = 0; i < motorPins.size(); i++)
{
pinMode(motorPins[i].pinIN1, OUTPUT);
pinMode(motorPins[i].pinIN2, OUTPUT);
rotateMotor(i, STOP);
}
}
void setup(void)
{
setUpPinModes();
Serial.begin(115200);
WiFi.softAP(ssid, password);
IPAddress IP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(IP);
ws.onEvent(onWebSocketEvent);
server.addHandler(&ws);
server.begin();
Serial.println("HTTP server started");
}
void loop()
{
ws.cleanupClients();
}
Bluetooth control car
Components :
1. Ardunio UNO
2. HC-05 Bluetooth Module
3. l293d Motor Driver
4. 4x DC Motor
Circuit Diagram :
Main Code :
Main Code :
#include <AFMotor.h>
#include <SoftwareSerial.h>
char command;
void setup()
{
bluetoothSerial.begin(9600); //Set the baud rate to your Bluetooth module.
}
void loop() {
if (bluetoothSerial.available() > 0) {
command = bluetoothSerial.read();
switch (command) {
case 'F':
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
}
}
}
void forward()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void back()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor anti-clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor anti-clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //rotate the motor anti-clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor anti-clockwise
}
void left()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor anti-clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor anti-clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void right()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //rotate the motor anti-clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor anti-clockwise
}
void Stop()
{
motor1.setSpeed(0); //Define minimum velocity
motor1.run(RELEASE); //stop the motor when release the button
motor2.setSpeed(0); //Define minimum velocity
motor2.run(RELEASE); //rotate the motor clockwise
motor3.setSpeed(0); //Define minimum velocity
motor3.run(RELEASE); //stop the motor when release the button
motor4.setSpeed(0); //Define minimum velocity
motor4.run(RELEASE); //stop the motor when release the button
}
Digital clock
Components :
1. Ardunio Nano
2. RTC Module
3. 32*2 Matrix Display
4. Push Button
Circuit Diagram :
Main Code :
Download Link -
Distance Measurement using Ultrasonic sensor
Components :
1. Ardunio Uno
2. Ultrasonic Sensor
3. 16x2 Display
4. Breadboard
Circuit Diagram :
Main Code :
Main Code :
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
long distanceInch;
void setup()
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Simple Circuits");
delay(2000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Distance:");
void loop()
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
distanceInch = duration*0.0133/2;
lcd.setCursor(9,0);
lcd.print(" ");
lcd.setCursor(9,0);
lcd.setCursor(9,1); //
lcd.setCursor(9,1);
lcd.print(distanceInch);
}
Object Avoding Robot
Components :
1. Ardunio Uno
2. Ultrasonic Sensor
3. l293d Motor Driver
4. Servo Motor
5. 4x DC Motor
Circuit Diagram :
Main Code :
Main Code :
// Before uploading the code you have to install the necessary library
//AFMotor Library https://learn.adafruit.com/adafruit-motor-shield/library-install
//NewPing Library https://github.com/livetronic/Arduino-NewPing
//Servo Library https://github.com/arduino-libraries/Servo.git
#include <AFMotor.h>
#include <NewPing.h>
#include <Servo.h>
#define TRIG_PIN A0
#define ECHO_PIN A1
#define MAX_DISTANCE 200
#define MAX_SPEED 190 // sets speed of DC motors
#define MAX_SPEED_OFFSET 20
boolean goesForward=false;
int distance = 100;
int speedSet = 0;
void setup() {
myservo.attach(10);
myservo.write(115);
delay(2000);
distance = readPing();
delay(100);
distance = readPing();
delay(100);
distance = readPing();
delay(100);
distance = readPing();
delay(100);
}
void loop() {
int distanceR = 0;
int distanceL = 0;
delay(40);
if(distance<=15)
{
moveStop();
delay(100);
moveBackward();
delay(300);
moveStop();
delay(200);
distanceR = lookRight();
delay(200);
distanceL = lookLeft();
delay(200);
if(distanceR>=distanceL)
{
turnRight();
moveStop();
}else
{
turnLeft();
moveStop();
}
}else
{
moveForward();
}
distance = readPing();
}
int lookRight()
{
myservo.write(50);
delay(500);
int distance = readPing();
delay(100);
myservo.write(115);
return distance;
}
int lookLeft()
{
myservo.write(170);
delay(500);
int distance = readPing();
delay(100);
myservo.write(115);
return distance;
delay(100);
}
int readPing() {
delay(70);
int cm = sonar.ping_cm();
if(cm==0)
{
cm = 250;
}
return cm;
}
void moveStop() {
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
}
void moveForward() {
if(!goesForward)
{
goesForward=true;
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2) // slowly bring the speed up to avoid loading down the batteries too quickly
{
motor1.setSpeed(speedSet);
motor2.setSpeed(speedSet);
motor3.setSpeed(speedSet);
motor4.setSpeed(speedSet);
delay(5);
}
}
}
void moveBackward() {
goesForward=false;
motor1.run(BACKWARD);
motor2.run(BACKWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2) // slowly bring the speed up to avoid loading down the batteries too quickly
{
motor1.setSpeed(speedSet);
motor2.setSpeed(speedSet);
motor3.setSpeed(speedSet);
motor4.setSpeed(speedSet);
delay(5);
}
}
void turnRight() {
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
delay(500);
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
}
void turnLeft() {
motor1.run(BACKWARD);
motor2.run(BACKWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
delay(500);
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
}
RFID Door Lock System
Components :
1. Ardunio Uno
2. RFID Tag
3. Servo Motor
4. Buzzer
5. 5MM Leds
6. Breadboard
Circuit Diagram :
Main Code :
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
#define SS_PIN 10
#define RST_PIN 9
#define LED_G 4 //define green LED pin
#define LED_R 5 //define red LED
#define BUZZER 2 //buzzer pin
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
Servo myServo; //define servo name
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
myServo.attach(3); //servo pin
myServo.write(0); //servo start position
pinMode(LED_G, OUTPUT);
pinMode(LED_R, OUTPUT);
pinMode(BUZZER, OUTPUT);
noTone(BUZZER);
Serial.println("Put your card to the reader...");
Serial.println();
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "83 23 38 BB") //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized access");
Serial.println();
delay(500);
digitalWrite(LED_G, HIGH);
tone(BUZZER, 500);
delay(300);
noTone(BUZZER);
myServo.write(180);
delay(5000);
myServo.write(0);
digitalWrite(LED_G, LOW);
}
else {
Serial.println(" Access denied");
digitalWrite(LED_R, HIGH);
tone(BUZZER, 300);
delay(1000);
digitalWrite(LED_R, LOW);
noTone(BUZZER);
}
}
Smart Dustbin
Components :
1. Ardunio Uno
2. Ultrasonic Sensor
3. Servo Motor
Circuit Diagram :
Main Code :
#include <Servo.h> //servo library
Servo servo;
int trigPin = 5;
int echoPin = 6;
int servoPin = 7;
int led= 10;
long duration, dist, average;
long aver[3]; //array for average
void setup() {
Serial.begin(9600);
servo.attach(servoPin);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
servo.write(0); //close cap on power on
delay(100);
servo.detach();
}
void measure() {
digitalWrite(10,HIGH);
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(15);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
dist = (duration/2) / 29.1; //obtain distance
}
void loop() {
for (int i=0;i<=2;i++) { //average distance
measure();
aver[i]=dist;
delay(10); //delay between measurements
}
dist=(aver[0]+aver[1]+aver[2])/3;
if ( dist<50 ) {
//Change distance as per your need
servo.attach(servoPin);
delay(1);
servo.write(0);
delay(3000);
servo.write(150);
delay(1000);
servo.detach();
}
Serial.print(dist);
}
Soil Moisture Sensor
Components :
1. Ardunio Nano
2. 0.91inch OLED Display
3. Soil Moisture Sensor
Circuit Diagram :
Main Code :
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
#define sensor A1
Adafruit_SSD1306 display(OLED_RESET);
void setup()
{
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //adddress(0x3C)
display.clearDisplay();
}
void loop()
{
int value = analogRead(sensor);
int percent = map(value, 1024, 0, 0, 100);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("MOISTURE");
display.print(percent);
display.print("%");
display.display();
display.clearDisplay();
}
Arduino Car Parking System
Components :
1. Arduino UNO
2. IR Proximity Sensor
3. Servo Motor
4. 16x2 LCD i2c Display
5. Jumpers
Circuit Diagram :
Main Code :
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2); //Change the HEX address
#include <Servo.h>
Servo myservo1;
int IR1 = 2;
int IR2 = 4;
int flag1 = 0;
int flag2 = 0;
void setup() {
lcd.begin();
lcd.backlight();
pinMode(IR1, INPUT);
pinMode(IR2, INPUT);
myservo1.attach(3);
myservo1.write(100);
lcd.setCursor (0,0);
lcd.print(" ARDUINO ");
lcd.setCursor (0,1);
lcd.print(" PARKING SYSTEM ");
delay (2000);
lcd.clear();
}
void loop(){
lcd.setCursor (0,0);
lcd.print(" WELCOME! ");
lcd.setCursor (0,1);
lcd.print("Slot Left: ");
lcd.print(Slot);
}
Arduino Voice Control Home Automation
Components :
1. Arduino UNO
2. HC-05 Bluetooth Module
3. 4-CH Relay Module
4. BreadBoard
Circuit Diagram :
Main Code :
#define relay1 2 //Connect relay1 to pin 2
#define relay2 3 //Connect relay2 to pin 3
#define relay3 4 //Connect relay3 to pin 4
#define relay4 5 //Connect relay4 to pin 5
String voice;
void setup()
{
Serial.begin(9600); //Set rate for communicating with phone
pinMode(relay1, OUTPUT); //Set relay1 as an output
pinMode(relay2, OUTPUT); //Set relay2 as an output
pinMode(relay3, OUTPUT); //Set relay3 as an output
pinMode(relay4, OUTPUT); //Set relay4 as an output
digitalWrite(relay1, HIGH); //Switch relay1 off
digitalWrite(relay2, HIGH); //Swtich relay2 off
digitalWrite(relay3, HIGH); //Switch relay3 off
digitalWrite(relay4, HIGH); //Swtich relay4 off
}
void loop()
{
while (Serial.available()){ //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = Serial.read(); //Conduct a serial read
if (c == '#') {break;} //Exit the loop when the # is detected after the word
voice += c; //Shorthand for voice = voice + c
}
if (voice.length() > 0)
{
if(voice == "*turn on light"){ //Voice Command to ON Relay 01
digitalWrite(relay1, LOW); //Relay 01 ON
}
else if(voice == "*turn on LED"){ //Voice Command to ON Relay 02
digitalWrite(relay2, LOW); //Relay 02 ON
}
else if(voice == "*turn on alarm") { //Voice Command to ON Relay 03
digitalWrite(relay3, LOW); //Relay 03 ON
}
else if(voice == "*turn on fan") { //Voice Command to ON Relay 04
digitalWrite(relay4, LOW); //Relay 04 ON
}
else if(voice == "*turn all devices on") { //Voice Command to ON all Relays
switchallon(); //All Relays ON
}
else if(voice == "*turn all devices off") { //Voice Command to OFF all Relays
switchalloff(); //All Relays OFF
}
Components :
1. Arduino
2. Dot Matrix 4 Channel Display
Circuit Diagram :
Main Code :
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR
#endif
#define PIN 8
#define mw 10
#define mh 5
void setup() {
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(40);
matrix.setTextColor(colors[0]);
}
int x = matrix.width();
int pass = 0;
void loop() {
matrix.fillScreen(0);
matrix.setCursor(x,0);
matrix.print(F("enter your text"));
if(--x < -50) {
x = matrix.width();
if(++pass >= 3) pass = 0;
matrix.setTextColor(colors[pass]);
}
matrix.show();
delay(70);
}
Arduino Digital Weight Scale
Components :
1. Arduino Nano
2. 16x2 I2c LCD Display
3. HX711 Module
4. 5kg Load Cell
5. BreadBoard
Circuit Diagram :
Main Code :
//Arduino Digital Weight Scale HX711 Load Cell Module
#include <HX711_ADC.h> // https://github.com/olkal/HX711_ADC
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // LiquidCrystal_I2C library
HX711_ADC LoadCell(4, 5); // dt pin, sck pin
LiquidCrystal_I2C lcd(0x27, 16, 2); // LCD HEX address 0x27
int taree = 6;
int a = 0;
float b = 0;
void setup() {
pinMode (taree, INPUT_PULLUP);
LoadCell.begin(); // start connection to HX711
LoadCell.start(1000); // load cells gets 1000ms of time to stabilize
/////////////////////////////////////
LoadCell.setCalFactor(375); // Calibarate your LOAD CELL with 100g weight,
and change the value according to readings
/////////////////////////////////////
if (i>=5000)
{
i=0;
lcd.setCursor(0, 0); // set cursor to secon row
lcd.print(" Over Loaded ");
delay(200);
}
if (digitalRead (taree) == LOW)
{
lcd.setCursor(0, 1); // set cursor to secon row
lcd.print(" Taring... ");
LoadCell.start(1000);
lcd.setCursor(0, 1);
lcd.print(" ");
}
}
Arduino Touch Sensor
Components :
1. Arduino
2. Touch Sensor TTP223B
3. Relay
4. LED
5. BreadBoard
6. Jumpers
Circuit Diagram :
Main Code :
int touchPin = 2;
int relayPin = 3;
int val = 0;
int lightON = 0;
int touched = 0;
void setup() {
Serial.begin(9600);
pinMode(touchPin, INPUT);
pinMode(relayPin, OUTPUT);
void loop() {
val = digitalRead(touchPin);
touched = 1-touched;
delay(100);
}
lightON = val;
if(touched == HIGH){
Serial.println("Light ON");
digitalWrite(relayPin, LOW);
}else{
Serial.println("Light OFF");
digitalWrite(relayPin, HIGH);
delay(100);
}
Arduino ECG Heart Rate Monitor AD8232
Components :
1. Arduino nano
2. ECG AD8232 Sensor
3. BreadBoard
4. Wires
Circuit Diagram :
Main Code :
void setup() {
// initialize the serial communication:
Serial.begin(9600);
pinMode(10, INPUT); // Setup for leads off detection LO +
pinMode(11, INPUT); // Setup for leads off detection LO -
void loop() {
Components :
1. Arduino
2. Solenoid Lock
3. 4x4 Keypad
4. Relay Module
5. Jumpers
Circuit Diagram :
Main Code :
#include <Keypad.h>
char* password = "123"; // change the password here, just pick any 3
numbers
int position = 0;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = { 9, 8, 7, 6 };
byte colPins[COLS] = { 5, 4, 3, 2 };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int Lock = 13;
void setup()
{
pinMode(Lock, OUTPUT);
LockedPosition(true);
}
void loop()
{
char key = keypad.getKey();
if (key == '*' || key == '#')
{
position = 0;
LockedPosition(true);
}
if (key == password[position])
{
position ++;
}
if (position == 3)
{
LockedPosition(false);
}
delay(100);
}
void LockedPosition(int locked)
{
if (locked)
{
digitalWrite(Lock, LOW);
}
else
{
digitalWrite(Lock, HIGH);
}
}
Arduino Voltmeter OLED Display
Components :
1. Arduino Nano
2. OLED Display
3. Voltage Sensor
4. Breadboard
5. Wires
Circuit Diagram :
Main Code :
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET A4
#define SSD1306_WHITE 1
#define SSD1306_BLACK 0
#define SSD1306_INVERSE 2
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
pinMode(analogInput, INPUT);
Serial.begin(9600);
Serial.println("VOLTMETER");
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.display();
display.clearDisplay();
display.display();
float R1 = 30000.0;
float R2 = 7500.0;
int value = 0;
void loop() {
value = analogRead(analogInput);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2 / (R1 + R2));
display.setTextSize(2);
display.setCursor(20, 15);
display.println(vin, 2);
display.setCursor(80, 15);
display.println("V");
display.display();
delay(1000);
}
Arduino Rotary Encoder controlled LEDs
Components :
1. Arduino Nano/UNO
2. 16x2 I2c LCD Display
3. Rotary Encoder
4. LED
5. Breadboard
6. Jumpers
Circuit Diagram :
Main Code :
Components :
1. Arduino UNO/NANO/PRO-Mini
2. OLED Display
3. Push Button
4. Breadboard
5. Wires
Circuit Diagram :
Main Code :
Circuit Diagram :
Main Code :
#define relay1 3 //Connect relay1 to pin D3
void setup()
{
Serial.begin(9600); //Set rate for communicating with phone
pinMode(relay1, OUTPUT); //Set relay1 as an output
digitalWrite(relay1, LOW); //Switch relay1 off
}
void loop()
{
while(Serial.available()) //Check if there are available bytes to read
{
delay(10); //Delay to make it stable
char c = Serial.read(); //Conduct a serial read
if (c == '#'){
break; //Stop the loop once # is detected after a
word
}
readString += c; //Means readString = readString + c
}
if (readString.length() >0)
{
Serial.println(readString);
1. Arduino UNO/NANO
2. 16x2 I2c LCD Display
3. HC-05 Bluetooth Module
4. Breadboard
Circuit Diagram :
Main Code :
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3C,16,2); //Change the HEX address
#include <SoftwareSerial.h>
SoftwareSerial mySerial (2, 3); //(RX, TX);
void setup()
{
// put your setup code here, to run once:
lcd.begin();
mySerial.begin(9600);
Serial.begin(9600);
lcd.setCursor(0, 0);
lcd.print(" Digital ");
lcd.setCursor(0, 1);
lcd.print(" Notice Board ");
delay(3000);
lcd.clear();
}
void loop()
{
val = mySerial.readString();
val.trim();
Serial.println(val);
if(val != oldval)
{
newval = val;
}
val = oldval;
Serial.println(val);
lcd.clear();
lcd.setCursor(16, 1);
lcd.print(newval);
lcd.setCursor(16, 0);
lcd.print("Notice:");
for(int counter = 0; counter < 24; counter++)
{
lcd.scrollDisplayLeft();
delay(500);
}
}
Arduino MPU6050 Digital Spirit Level Measuring Device
Components :
1. Arduino NANO
2. MPU6050
3. OLED Display
4. Buzzer
5. LED
6. Breadboard
Circuit Diagram :
Main Code :
Components :
Circuit Diagram :
Main Code :
Components :
1. Arduino NANO
2. HC-05 Bluetooth Module
3. 4channel Relay Module
4. BreadBoard
Circuit Diagram :
Main Code :
#define relay1 2 //Connect relay1 to pin 2
#define relay2 3 //Connect relay2 to pin 3
#define relay3 4 //Connect relay3 to pin 4
#define relay4 5 //Connect relay4 to pin 5
void setup()
{
Serial.begin(9600); //Set rate for communicating with phone
pinMode(relay1, OUTPUT); //Set relay1 as an output
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT); //Set relay2 as an output
pinMode(relay4, OUTPUT);
digitalWrite(relay1, HIGH); //Switch relay1 off
digitalWrite(relay2, HIGH); //Swtich relay2 off
digitalWrite(relay3, HIGH); //Switch relay1 off
digitalWrite(relay4, HIGH); //Swtich relay2 off
}
void loop()
{
while(Serial.available()) //Check if there are available bytes to read
{
delay(10); //Delay to make it stable
char c = Serial.read(); //Conduct a serial read
if (c == '#'){
break; //Stop the loop once # is detected after a word
}
readString += c; //Means readString = readString + c
}
if (readString.length() >0)
{
Serial.println(readString);
if(readString == "switch all on"){
switchallon();
}
else if(readString == "switch all off"){
switchalloff();
}
else if(readString == "relay1 on"){
digitalWrite(relay1, LOW);
}
else if(readString == "relay1 off"){
digitalWrite(relay1, HIGH);
}
else if(readString == "relay2 on"){
digitalWrite(relay2, LOW);
}
else if(readString == "relay2 off"){
digitalWrite(relay2, HIGH);
}
else if(readString == "relay3 on"){
digitalWrite(relay3, LOW);
}
else if(readString == "relay3 off"){
digitalWrite(relay3, HIGH);
}
else if(readString == "relay4 on"){
digitalWrite(relay4, LOW);
}
else if(readString == "relay4 off"){
digitalWrite(relay4, HIGH);
}
readString="";
}
}
void switchalloff() //Function for turning OFF all relays
{
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
}
void switchallon() //Function for turning ON all relays
{
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
digitalWrite(relay4, LOW);
}
Arduino Shake DICE OLED Display
Components :
1. Arduino UNO/NANO
2. OLED Display
3. Push Tactile Buttons
4. Buzzer
5. Vibration Sensor
6. Breadboard
7. Wires
Circuit Diagram :
Main Code :
Main Code :
1. Arduino
2. MPU6050
3. Servo
4. Breadboard
5. Jumpers
Circuit Diagram :
Main Code :
Components :
1. Arduino Uno
2. RFID Sensor
3. Solenoid Lock
4. LED
5. Buzzer
6. Breadboard
7. Relay Module
8. Push Button
9. BreadBoard
Circuit Diagram :
Main Code :
Thank you once again for choosing our Arduino projects eBook. May
it serve as a valuable companion on your journey of exploration
and discovery.
Happy tinkering!
Sincerely,
@Mr_circuits007