Requirements
No necessary requirement, Basic knowledge of Electronics will be great advantage
Fundamentals of Robotics
Robotics is fundamentally a branch of technology that deals with the design, construction, operation, and application of robots. It is a powerful tool to understand the basic concepts of Computer Science, Mechanical engineering, and Electronics engineering. In this Arduino robot course will use a simplified version of C++ language for programming our Robot using the Arduino IDE.
Course Content and Overview
This course is designed for students interested in controlling an Arduino Robot with Android Smartphone. basic coding experience is required; Learn Arduino in Urdu for Free all you need is an Arduino, Bluetooth, some hardware and electronics component for building the Robot. We will start from basics of Arduino programming and then move to higher topics.
Basics of Arduino
Learn Arduino in Urdu and understand the basics of Arduino and then we will look at Arduino installation & setting up Arduino with your Computer or Laptop
Construction of Robot
After understanding the basics of Arduino next we will construct our Arduino Robot. All the components required for building this Robot are mentioned in Section 2
Time Control Robot
In the Time Control Robot section you will first understand the working of Motors Driver and how to control 2 motors using a single motor driver.
We will then write Arduino program so that the Robot moves in the following direction for a specific period of time
- Forward
- Backward
- Axial Left
- Axial Right
- Radial Right
- Radial Left
- Stop
Serial Communication
Serial Communication is essential for sending and receiving data between Electronic hardware devices. We will use Serial Communication to control Led’s, Potentiometer sensor and the Arduino Robot.
In this section you will learn to read analog values from sensors and display it on the Serial Monitor. You will also write (send data) values from PC to Arduino.
Android Programming
Android OS has taken the world by storm after its inception nearly 10 years back. One of the major benefits of owning an Android smartphone is the ability to use it as a Remote Control for controlling Robots and other Electronics devices.
In this course we will design 5 Android Applications using a tool called AppInventor2. AppInventor2 is a Graphical Programming Software using which even a non programmer can design amazing Android apps in a matter of minutes.
Controlling Arduino Robot using Android Smartphone
We will create 3 android applications for controlling the Arduino and each application works in different manner
SmartBot
In the Smartbot android app we will create 5 buttons (Forward, Backward, Left, Right and Stop). When the user clicks on any of the button the Robot will move in that particular direction.
AcceleroControl Robot
In the AcceleroControl Robot android app, we will use the accelerometer sensor from the android smartphone to control the Robot. So when the user tilts the robot in forward direction it will will move forward, when the Smartphone is kept flat the Robot will Stop. Similarly by pointing the smartphone in direction you can control the direction of the Arduino Robot.
Object Avoider Robot
Object avoider robot or Maze solver robot is similar to object repeller robot, but in certain condition, it will simply avoid the object instead of moving away from it.
working code
#include
// Define the Bluetooth serial pins
SoftwareSerial Bluetooth(10, 11); // RX, TX
// Motor control pins
int motor1Pin1 = 4; // Motor 1 direction pin
int motor1Pin2 = 5; // Motor 1 direction pin
int motor2Pin1 = 7; // Motor 2 direction pin
int motor2Pin2 = 8; // Motor 2 direction pin
int enPin1 = 3; // Motor 1 enable pin (PWM)
int enPin2 = 6; // Motor 2 enable pin (PWM)
// Define speed (PWM) for motors
int speed = 200; // Adjust speed from 0 to 255
void setup() {
// Set motor pins as outputs
pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(motor2Pin1, OUTPUT);
pinMode(motor2Pin2, OUTPUT);
pinMode(enPin1, OUTPUT);
pinMode(enPin2, OUTPUT);
// Start the Bluetooth serial communication
Bluetooth.begin(9600);
Serial.begin(9600);
// Initial Debug Message
Serial.println(“Setup complete. Awaiting Bluetooth commands…”);
}
void loop() {
// Check if data is received from Bluetooth
if (Bluetooth.available()) {
char command = Bluetooth.read();
Serial.print(“Received command: “);
Serial.println(command); // Print command to Serial Monitor for debugging
// Control robot movement based on received command
if (command == ‘F’) {
Serial.println(“Moving Forward”);
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
analogWrite(enPin1, speed);
analogWrite(enPin2, speed);
}
else if (command == ‘B’) {
Serial.println(“Moving Backward”);
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
analogWrite(enPin1, speed);
analogWrite(enPin2, speed);
}
else if (command == ‘L’) {
Serial.println(“Turning Left”);
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
analogWrite(enPin1, speed);
analogWrite(enPin2, speed);
}
else if (command == ‘R’) {
Serial.println(“Turning Right”);
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
analogWrite(enPin1, speed);
analogWrite(enPin2, speed);
}
else if (command == ‘S’) {
Serial.println(“Stopping”);
digitalWrite(enPin1, LOW);
digitalWrite(enPin2, LOW);
} else {
Serial.println(“Unknown command received”);
}
}
// For testing purposes, check if any message is being received by Bluetooth
else {
Serial.println(“Waiting for Bluetooth command…”);
delay(10); // Wait 1 second before re-checking
}
}