Dayyan Project
Dayyan Project
1. Microcontroller: The brain of the robot, typically an Arduino, Raspberry Pi, or similar
device.
2. Motors and Motor Drivers: Used for movement, typically DC motors with motor
drivers like L298N.
3. Power Supply: Batteries to power the robot.
4. Sensors: Sensors are crucial for detecting and following the human. Commonly used
sensors include:
o Ultrasonic Sensors: Measure distance by sending and receiving sound waves.
o Infrared (IR) Sensors: Detect obstacles or track objects.
o LIDAR: For more advanced distance and object detection.
o Camera with Computer Vision: For more sophisticated tracking.
5. Transmitters and Receivers: Used for wireless communication between the robot and
external devices, or for processing sensor data.
o RF Modules: For basic remote control.
o Bluetooth: For communication with a smartphone.
o Wi-Fi: For more advanced communication and remote monitoring.
o Zigbee: For low-power, long-range communication.
1. Chassis Assembly: Mount the motors on the chassis and connect the wheels. Attach the
motor driver to the chassis.
2. Mount Sensors: Place the sensors at the appropriate locations. For example, ultrasonic
sensors should be placed at the front to detect obstacles and measure distance to the
human.
3. Microcontroller Setup: Mount the microcontroller on the chassis, ensuring that it's
securely attached. Connect the microcontroller to the motor driver, sensors, and any other
peripherals.
Connections:
void setup() {
Serial.begin(9600);
void loop() {
uint8_t buf[VW_MAX_MESSAGE_LEN];
int i;
Serial.print(buf[i]);
Serial.println("");
}
2) Using Bluetooth Modules (e.g., HC-05):
Transmitter and Receiver: The Bluetooth module handles both transmitting and
receiving data.
Use a smartphone app or another Bluetooth-enabled device to control the robot.
Connections:
Connect the HC-05 module to the microcontroller (TXD to RX, RXD to TX).
Code Example:
#include <SoftwareSerial.h>
void setup() {
Serial.begin(9600);
BTSerial.begin(9600);
void loop() {
if (BTSerial.available()) {
char c = BTSerial.read();
Serial.write(c);
Transmitter and Receiver: Both are integrated into the Wi-Fi module. The robot can be
controlled over the network.
This allows for more complex operations, like streaming video from a camera, using
computer vision algorithms, or remote control via a web interface.
Connections:
Connect the Wi-Fi module to the microcontroller. It can also function as the
microcontroller itself (ESP32).
Code Example:
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
delay(1000);
Serial.println("Connecting...");
Serial.println("Connected");
void loop() {
CODE:
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Move forward
// Move backward
} else {
// Stop
3) Movement Control:
void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, HIGH);
void loop() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
}
2nd Method:
Objective: Build a robot that can follow a human using an ultrasonic sensor for distance
measurement and a Bluetooth module for remote control via a smartphone.
Components:
o Arduino Uno (or similar microcontroller)
o L298N Motor Driver Module
o DC Motors (with wheels)
o Ultrasonic Sensor (HC-SR04)
o Bluetooth Module (HC-05)
o Chassis
o 12V Battery Pack
o Jumper Wires
1. Chassis Setup:
o Attach the DC motors to the chassis.
o Mount the wheels on the motors.
o Attach the motor driver module to the chassis.
2. Ultrasonic Sensor Placement:
o Place the HC-SR04 ultrasonic sensor at the front of the robot to measure the
distance from the human.
3. Arduino and Bluetooth Module:
o Mount the Arduino on the chassis.
o Attach the HC-05 Bluetooth module to the Arduino.
4. Connections:
o Motor Driver (L298N):
IN1 to Arduino Pin 8
IN2 to Arduino Pin 9
IN3 to Arduino Pin 10
IN4 to Arduino Pin 11
ENA to Arduino Pin 5 (for speed control of motor 1)
ENB to Arduino Pin 6 (for speed control of motor 2)
OUT1 and OUT2 to one motor
OUT3 and OUT4 to another motor
Connect VCC and GND to the battery pack
o Ultrasonic Sensor (HC-SR04):
VCC to Arduino 5V
GND to Arduino GND
Trig to Arduino Pin 7
Echo to Arduino Pin 6
o Bluetooth Module (HC-05):
VCC to Arduino 5V
GND to Arduino GND
TXD to Arduino Pin 2 (RX)
RXD to Arduino Pin 3 (TX)
Below is the complete Arduino code for the human-following robot with Bluetooth control. The
code reads distance data from the ultrasonic sensor and commands the motors accordingly. The
Bluetooth module allows remote control via a smartphone.
CODE:
#include <AFMotor.h>
#include <NewPing.h>
#include <SoftwareSerial.h>
#define ENA 5
#define ENB 6
#define IN1 8
#define IN2 9
#define IN3 10
#define IN4 11
#define TRIG_PIN 7
#define ECHO_PIN 6
#define RX_PIN 2
#define TX_PIN 3
void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT);
void loop() {
} else {
if (BTSerial.available()) {
if (command == 'F') {
moveForward();
turnLeft();
turnRight();
stopMotors();
void moveForward() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void moveBackward() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
void turnLeft() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
void turnRight() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
void stopMotors() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
To control the robot using Bluetooth, you can use a Bluetooth terminal app available on Android
or iOS. You can send the following commands to the robot:
F: Move Forward
B: Move Backward
L: Turn Left
R: Turn Right
S: Stop