Carrer Guidance Program
Carrer Guidance Program
Career Guidance
Program-Electronics
1|Page
Activity-1
Introduction to Robotics
Objective:
1. Bluetooth-Controlled Robot
2. Radar System with Arduino Uno
3. Home Automation System using ESP8266
Projects Overview:
• Bluetooth-Controlled Robot:
A robot controlled remotely using a smartphone and Bluetooth
module.
• Radar System Using Arduino:
A system to detect and measure the distance of objects using
ultrasonic sensors.
• Home Automation Using ESP8266:
A smart system to control home devices using sensors and
ESP8266 microcontroller.
2|Page
Components Required:
6 Motor driver circuit L298N Motor Driver Shield or relative Driver Shield
3|Page
10 Screw driver set Compact and Portable pocket toolkit
30 different head style
Rubber Shockproof gripped handle
Strong and durable plastic Case
Colour: Yellow-Red
Interchangeable Precise Manual Tool Kit.
11 12v battery jack 12 volt battery clips with DC Jack
12 Adhesive tape Tape- 5mm/10mm wide
13 Robot chassis It can be used for distance measurement, velocity.
Can use with other devices to realize function of
tracing, obstacle avoidance, distance testing, speed
testing,
Wireless remote control.
Size: 21 x 15 cm (L x W).
Wheel size: 6.5 x 2.7cm (Dia. x H).
14 Connecting wires(MF,FF,MM) Dupont Cable Color Jumper Wire, 2.54mm 1P-1P
Strip M/M, M/F, F/F
15 Bulb Energy Efficient
4|Page
Activity-2
Bluetooth-Controlled Robot:
Components Required:
Working Principle:
The smartphone sends control signals via Bluetooth to the Arduino. Arduino
interprets the commands and controls the motors via the motor driver.
Circuit Diagram:
The connection between the Arduino, Bluetooth module, motor driver, and
motors.
5|Page
Block Diagram:
Arduino code:
#include <SoftwareSerial.h>
void setup() {
// Initialize serial communication with Bluetooth module
bluetooth.begin(9600);
6|Page
stopMotors();
}
void loop() {
if (bluetooth.available()) {
char command = bluetooth.read();
executeCommand(command);
}
}
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);
7|Page
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);
}
8|Page
Activity-3
Radar System with Arduino Uno
Working Principle:
A radar system using Arduino Uno works by emitting radio waves through a
transmitter and receiving the reflected waves using a receiver. The Arduino
processes the time delay between transmission and reception to calculate the
distance of an object and display the results.
Circuit Diagram:
The connection between the Arduino Uno, Ultrasonic sensor and Servo
motor.
Block Diagram:
9|Page
Steps to run:
https://processing.org/download
In line 19, change "COM3" to the correct serial port where your Arduino is
connected. You can check the port on the following systems:
The radar system should now appear on the Processing IDE window,
displaying the distance as a line based on the angle.
Arduino code:
#include <Servo.h>.
// Defines Tirg and Echo pins of the Ultrasonic Sensor
const int trigPin = 10;
const int echoPin = 9;
// Variables for the duration and the distance
10 | P a g e
long duration;
int distance;
Servo myServo; // Creates a servo object for controlling the servo motor
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600);
myServo.attach(3); // Defines on which pin is the servo motor attached
}
void loop() {
// rotates the servo motor from 15 to 165 degrees
for(int i=15;i<=165;i++){
myServo.write(i);
delay(30);
distance = calculateDistance();// Calls a function for calculating the distance
measured by the Ultrasonic sensor for each degree
11 | P a g e
Serial.print(",");
Serial.print(distance);
Serial.print(".");
}
}
// Function for calculating the distance measured by the Ultrasonic sensor
int calculateDistance(){
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave
travel time in microseconds
distance= duration*0.034/2;
return distance;
}
Processing Code:
12 | P a g e
int index1=0;
int index2=0;
PFont orcFont;
void setup() {
}
void draw() {
fill(98,245,31);
13 | P a g e
// reads the data from the Serial Port up to the character '.' and puts it into the String
variable "data".
data = myPort.readStringUntil('.');
data = data.substring(0,data.length()-1);
index1 = data.indexOf(","); // find the character ',' and puts it into the variable
"index1"
angle= data.substring(0, index1); // read the data from position "0" to position of the
variable index1 or thats the value of the angle the Arduino Board sent into the Serial
Port
distance= data.substring(index1+1, data.length()); // read the data from position
"index1" to the end of the data pr thats the value of the distance
14 | P a g e
line(0,0,-960*cos(radians(120)),-960*sin(radians(120)));
line(0,0,-960*cos(radians(150)),-960*sin(radians(150)));
line(-960*cos(radians(30)),0,960,0);
popMatrix();
}
void drawObject() {
pushMatrix();
translate(960,1000); // moves the starting coordinats to new location
strokeWeight(9);
stroke(255,10,10); // red color
pixsDistance = iDistance*22.5; // covers the distance from the sensor from cm to
pixels
// limiting the range to 40 cms
if(iDistance<40){
// draws the object according to the angle and the distance
line(pixsDistance*cos(radians(iAngle)),-
pixsDistance*sin(radians(iAngle)),950*cos(radians(iAngle)),-
950*sin(radians(iAngle)));
}
popMatrix();
}
void drawLine() {
pushMatrix();
strokeWeight(9);
stroke(30,250,60);
translate(960,1000); // moves the starting coordinats to new location
line(0,0,950*cos(radians(iAngle)),-950*sin(radians(iAngle))); // draws the line
according to the angle
popMatrix();
}
15 | P a g e
void drawText() { // draws the texts on the screen
pushMatrix();
if(iDistance>40) {
noObject = "Out of Range";
}
else {
noObject = "In Range";
}
fill(0,0,0);
noStroke();
rect(0, 1010, width, 1080);
fill(98,245,31);
textSize(25);
text("10cm",1180,990);
text("20cm",1380,990);
text("30cm",1580,990);
text("40cm",1780,990);
textSize(40);
text("Object: " + noObject, 240, 1050);
text("Angle: " + iAngle +" °", 1050, 1050);
text("Distance: ", 1380, 1050);
if(iDistance<40) {
text(" " + iDistance +" cm", 1400, 1050);
}
textSize(25);
fill(98,245,60);
translate(961+960*cos(radians(30)),982-960*sin(radians(30)));
rotate(-radians(-60));
text("30°",0,0);
resetMatrix();
translate(954+960*cos(radians(60)),984-960*sin(radians(60)));
rotate(-radians(-30));
16 | P a g e
text("60°",0,0);
resetMatrix();
translate(945+960*cos(radians(90)),990-960*sin(radians(90)));
rotate(radians(0));
text("90°",0,0);
resetMatrix();
translate(935+960*cos(radians(120)),1003-960*sin(radians(120)));
rotate(radians(-30));
text("120°",0,0);
resetMatrix();
translate(940+960*cos(radians(150)),1018-960*sin(radians(150)));
rotate(radians(-60));
text("150°",0,0);
popMatrix();
}
17 | P a g e
Activity-4
Working Principle:
Circuit Diagram:
Block diagram:
18 | P a g e
Arduino code:
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
void setup() {
// Begin serial communication for debugging
Serial.begin(115200);
// Connect to Wi-Fi
Serial.println("Connecting to Wi-Fi...");
WiFi.begin(ssid, password);
Serial.println();
Serial.println("Connected to Wi-Fi!");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
19 | P a g e
HTTPClient http;
// Start connection and send the GET request using the updated API if
(http.begin(wifiClient, serverUrl)) { // Pass WiFiClient object and URL
int httpCode = http.GET();
if (httpCode > 0) { //
HTTP response received
Serial.printf("HTTP Response code: %d\n", httpCode);
String payload = http.getString();
Serial.println("Payload: " + payload);
Python code:
app = Flask(_name_)
20 | P a g e
status="off" @app.route('/') def
home():
return render_template('index1.html', button_status=button_status["status"])
@app.route('/toggle', methods=['GET'])
def toggle(): global status
# Toggle the button state if
button_status["status"] == "OFF":
status = 'on'
button_status["status"] = "ON"
else:
button_status["status"] = "OFF"
status='off'
return jsonify(status=button_status["status"])
@app.route('/fetch', methods=['GET'])
def fetch():
global status
print(status)
return str(status)
if _name_ == '_main_':
app.run(debug=True, host='0.0.0.0')
Html code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Automation</title>
<style>
/* Global Styles */
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
background-size: cover; /* Ensures background covers the entire page */
background-position: center;
background-repeat: no-repeat;
21 | P a g e
margin: 0;
padding: 0;
text-align: center;
}
nav {
background-color: white; /* Set navbar background to white */
padding: 20px 0; /* Vertical padding for space inside the navbar */
position: relative;
display: flex;
justify-content: center;
align-items: center;
border-bottom: 2px solid #ddd; /* Optional: adds a subtle border at the bottom */
height: 54px; /* Adjust this height to make the navbar bigger */
}
nav h1 {
color: black;
margin: 0;
font-size: 24px;
font-weight: bold;
}
nav img {
position: absolute;
right: 20px;
top: -15px;
width: 100px;
height: auto;
}
22 | P a g e
/* Left Section (Push Button and Status) */
.left-section {
flex: 1;
background-color: white;
padding: 20px;
margin-right: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
height: 250px; /* Set a fixed height */
width: 250px; /* Set width equal to height for a square */
display: flex;
flex-direction: column;
justify-content: center;
}
h2 {
color: #333;
font-size: 28px;
}
button {
padding: 15px 30px;
font-size: 18px;
border: none;
cursor: pointer;
23 | P a g e
background-color: #007bff;
color: white;
border-radius: 5px;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
.status {
margin-top: 20px;
font-size: 20px;
color: #333;
}
/* Responsive Styles */
@media (max-width: 600px) {
.content {
flex-direction: column;
padding: 20px;
}
.left-section,
.right-section {
margin-right: 0;
margin-bottom: 20px;
height: auto;
}
nav h1 {
font-size: 20px;
}
button {
width: 100%;
padding: 12px;
}
nav img {
width: 120px;
}
}
</style>
</head>
24 | P a g e
<body>
<nav>
<img src="static/karnataka.png" alt="Karnataka Logo" class="left-image">
<h1>Home Automation</h1>
<img src="static/gttc.png" alt="Logo" class="right-logo">
</nav>
<div class="content">
<!-- Left Section for Button and Status -->
<div class="left-section">
<h2>Push Button ON/OFF</h2>
<button id="toggle-button">Toggle</button>
<div class="status">Current Status: <span id="status">OFF</span></div>
</div>
<script>
const button = document.getElementById('toggle-button');
const statusSpan = document.getElementById('status');
button.addEventListener('click', async () => {
// Use GET method instead of POST
const response = await fetch('/toggle', { method: 'GET' });
const data = await response.json();
statusSpan.textContent = data.status;
});
</script>
</body>
</html>
https://autohome.pythonanywhere.com/
25 | P a g e