Technical Science II Robotics Hand Guide
Technical Science II Robotics Hand Guide
1
Introduction
What is Robotics?
Robotics is about creating smart machines called robots. These robots can do tasks
on their own or with some help. They can be programmed to do things like cleaning,
building, or exploring places that might be risky for people.
More.
Fun Fact:
The word "robot" comes from the Czech word "robota," which means forced labor or
work.
You can be a future robot creator, programmer, or even a robotics engineer. The
possibilities are endless!
2
Parts of a Robot
Robots consist of several essential parts that work together to enable their
functionality. Here are the main components of robots:
1.Sensors:
2.Actuators:
- Function: Actuators are responsible for the movement and manipulation of the
robot. They convert electrical signals into physical actions, allowing the robot to
perform tasks.
3.Controller/Processor:
4. Power Supply:
- Function: Robots need a source of power to operate. This can be in the form of
batteries, electricity, or a combination of power sources.
3
- Examples: Rechargeable batteries, power cables.
5. Mechanical Structure:
- Function: The mechanical structure provides the physical framework and support
for the robot. It determines the robot's shape, size, and range of motion.
6. End-Effector/Manipulator:
- Function: The end-effector or manipulator is the tool or device at the end of the
robot's arm that interacts with the environment or performs specific tasks.
7. Communication Interface:
- Function: Robots often need to communicate with other devices or systems. The
communication interface enables data exchange between the robot and external
sources.
8. Programming Interface:
4
9. Feedback System:
- Function: Robots may have a feedback system to receive information about their
own state or the success of a task. This helps in adjusting actions for better
performance.
Understanding these components provides insight into how robots function and how
they can be designed for specific applications. Depending on the type and purpose
of the robot, these parts may vary in complexity and arrangement.
5
Types of Robots
Certainly! There are several main types of robots, each designed for specific
purposes. Here are some of the key categories:
1. Industrial Robots:
- Purpose: Used in manufacturing and industrial settings for tasks like welding,
assembly, painting, and packaging.
2. Service Robots:
3. Educational Robots:
- Purpose: Designed to help people, especially students, learn about robotics and
programming.
4. Medical Robots:
- Purpose: Used in healthcare for tasks like surgery, rehabilitation, and diagnostics.
6
5. Military and Defense Robots:
- Purpose: Used for tasks in military and defense applications to reduce risks to
human personnel.
6. Entertainment Robots:
- Examples: Robotic toys, animatronics in theme parks, and interactive robots for
entertainment shows.
7. Domestic Robots:
- Examples: Robotic vacuum cleaners, lawn mowers, and smart home devices.
8. Research Robots:
- Examples: Humanoid robots used for studying human behavior, robot arms for
research purposes.
7
9. Humanoid Robots:
- Purpose: Vehicles that can operate without human intervention, often using
robotics and artificial intelligence.
8
How to Program Robots
Programming robots involves providing a set of instructions that the robot follows to
perform specific tasks. The programming language and approach can vary
depending on the type of robot and the complexity of the task. Here's a general
overview of robot programming:
- Choose a programming language suitable for the robot's hardware and your skill
level.
- Start with simple movements to understand how to control the robot's actuators.
4. Sensor Integration:
9
- Incorporate sensor data into your program to make the robot responsive to its
environment.
6. Loops:
- For more advanced programming, consider using OOP principles if the chosen
language supports it.
- For mobile robots, implement algorithms for path planning and navigation.
- Use mapping and localization techniques to help the robot navigate its
environment.
10
10. Testing and Debugging:
- Test your code in a controlled environment before deploying it in the real world.
- Debug any issues and refine your program for better performance.
12. Documentation:
- Document your code to make it easy for others (or yourself) to understand and
maintain.
Remember that the specifics of robot programming can vary based on the type of
robot and its intended application. Whether you're working with educational robots,
industrial robots, or autonomous vehicles, adapting your programming approach to
the specific requirements is essential.
Exciting Trends
11
Chapter 1 - ESP 32
12
The ESP32 Dev Module is a development board based on the ESP32
microcontroller, which is a powerful and versatile chip designed for IoT (Internet of
Things) applications. Here's an overview of the ESP32 Dev Module and some key
information:
1. Microcontroller:
2. Wireless Connectivity:
- Built-in Wi-Fi (802.11 b/g/n) and Bluetooth (Bluetooth Low Energy) capabilities.
- Allows for IoT applications, connecting to the internet, and communication with
other devices.
3. GPIO Pins:
4. Programming Interface:
13
5. Integrated Peripherals:
- Supports various protocols for communication with sensors and other devices.
6. Memory:
7. Power Options:
8. Development Environment:
- Arduino core for ESP32 allows for easy and familiar programming.
9. Form Factor:
14
ESP 32 for what?
The ESP32 microcontroller is highly versatile and finds applications in a wide range
of projects, especially in the field of IoT (Internet of Things). Here are some common
usages of the ESP32:
1. IoT Devices:
- ESP32 is widely used in IoT applications due to its built-in Wi-Fi and Bluetooth
capabilities. It can connect to the internet, enabling devices to communicate and
share data.
2. Home Automation:
- ESP32-based devices are used in smart home applications for controlling lights,
thermostats, door locks, and other home appliances remotely.
3. Sensor Networks:
- ESP32 can interface with various sensors (temperature, humidity, motion, etc.)
and create sensor networks for monitoring and data collection.
4. Industrial Automation:
5. Robotics:
- ESP32 can be used in robotics projects for motor control, sensor integration, and
wireless communication. It's suitable for both educational and hobbyist robotics
applications.
15
6. Wearable Devices:
- Due to its small form factor and low power consumption, ESP32 is used in
wearable electronics, including smartwatches, fitness trackers, and health monitoring
devices.
7. Data Logging:
- With its ability to interface with sensors and store data, ESP32 is often used for
data logging applications, such as weather stations, environmental monitoring, and
energy consumption tracking.
8. Wireless Communication:
9. Educational Projects:
16
12. Audio Processing:
- The ESP32 features capabilities for audio processing, making it suitable for
projects involving sound, music, and voice recognition applications.
- ESP32 can be integrated into security systems for tasks such as surveillance
camera control, access control, and monitoring.
- ESP32 allows for remote monitoring and control of devices and systems, making
it suitable for applications like remote home security, smart agriculture, and industrial
monitoring.
These are just a few examples, and the applications of the ESP32 are continuously
expanding as developers explore its capabilities in various projects. The versatility,
low cost, and ease of use make the ESP32 a popular choice in the maker and IoT
communities.
17
Getting Started:
- Use a USB cable to connect the ESP32 Dev Module to your computer.
- In the Arduino IDE, select the ESP32 Dev Module as the target board.
4. Upload Code:
- Write or open a sample code and upload it to the ESP32 Dev Module.
- Open the serial monitor in the Arduino IDE to view the output and debug
messages.
18
Chapter 2 – LED Blinking
Certainly! Blinking an LED is a common beginner's project to get started with the
ESP32..
Here's a step-by-step guide to help you set up and run the code:
- Connect the longer leg (anode) of the LED to pin 13 on the ESP32.
- Connect the shorter leg (cathode) of the LED to the ground (GND) pin on the
ESP32.
19
2. Set Up Arduino IDE:
- Make sure you have the Arduino IDE installed on your computer.
- Add the ESP32 board support to the Arduino IDE. You can follow the instructions
provided by Espressif: [Installing the ESP32 Board in Arduino IDE]
- Select the "ESP32 Dev Module" board from the "Tools" > "Board" menu.
- Choose the correct COM port from the "Tools" > "Port" menu.
- Copy and paste the provided code into the Arduino IDE.
- Click the "Upload" button (arrow icon) to upload the code to the ESP32.
- After the code is uploaded, the LED connected to pin 13 on the ESP32 should
start blinking.
20
CODE
Below is a simple example code using the Arduino IDE This code will make an LED
connected to pin 13 on the ESP32 Dev Module blink:
void setup() {
// Set the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Turn the LED on (HIGH)
digitalWrite(ledPin, HIGH);
This simple project is a great way to verify that your ESP32 development
environment is set up correctly and that you can successfully upload code to the
board.
21
More – Blink Multiple LEDs
void setup() {
// Set the LED pins as outputs
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}
void loop() {
// Turn the first LED on (HIGH) for 1 second
digitalWrite(ledPin1, HIGH);
delay(1000);
digitalWrite(ledPin1, LOW);
22
delay(1000);
digitalWrite(ledPin3, LOW);
In this code:
- `ledPin1`, `ledPin2`, and `ledPin3` represent the GPIO pins to which the LEDs are
connected.
- Inside the `setup` function, these pins are set as outputs using `pinMode`.
- The `loop` function contains a sequence to turn each LED on for 1 second and then
off, repeating the process for each LED.
- A delay of 1 second is added between each LED action to make the blinking easily
observable.
You can modify the code further by adding more LED pins and adjusting the delays
according to your preferences. Make sure to connect the LEDs to the specified GPIO
pins on the ESP32.
23
Chapter 3 – Sensors
Here are the step-by-step instructions for connecting an IR sensor and an LED to
your ESP32:
Components Required:
3. LED
5. Jumper wires
24
Pin Connections:
1. IR Sensor to ESP32:
- Connect the VCC (power) pin of the IR sensor to the 3.3V pin on the ESP32.
- Connect the GND (ground) pin of the IR sensor to the GND pin on the ESP32.
- Connect the OUT (signal) pin of the IR sensor to a digital input pin on the ESP32
(e.g., pin 33 as per your code).
2. LED to ESP32:
- Connect the anode (longer leg) of the LED to a current-limiting resistor (if
needed) and then connect it to a digital output pin on the ESP32 (e.g., pin 32 as per
your code).
- Connect the cathode (shorter leg) of the LED to the GND pin on the ESP32.
25
Wiring Example:
-------------------------------------
Notes:
- Ensure that the IR sensor and LED have their specifications and pinouts available
and match them accordingly.
- Double-check the polarity of the LED. The longer leg is the anode (+), and the
shorter leg is the cathode (-).
- Make sure the connections are secure, and there are no loose wires.
- Modify the code if you change the pin assignments in your hardware connections.
After making the connections, upload your code to the ESP32, open the Serial
Monitor in the Arduino IDE to monitor the IR sensor readings, and observe the LED
responding to the IR sensor's output.
26
CODE
#include <Arduino.h>
const int irSensor = 33; // Pin connected to the IR sensor
const int ledPin = 32; // Pin connected to the LED
int irReading;
void setup()
{
Serial.begin(115200); // Initialize serial communication for debugging
pinMode(irSensor, INPUT); // Set the IR sensor pin as INPUT
pinMode(ledPin, OUTPUT); // Set the LED pin as OUTPUT
}
void loop()
{
irReading = digitalRead(irSensor); // Read the state of the IR sensor
// If the IR sensor detects an object (LOW state), turn on the LED; otherwise, turn it
off
if (irReading == LOW)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}
27
Ultrasonic Sensor with ESP 32
To use an ultrasonic sensor with an ESP32, you can measure the distance to an
object by sending ultrasonic waves and measuring the time it takes for the waves to
bounce back.
Here's a step-by-step guide to help you set up and run this code:
Components Required:
3. Jumper wires
28
Pin Connections:
- Connect the VCC (power) pin of the ultrasonic sensor to the 5V pin on the
ESP32.
- Connect the GND (ground) pin of the ultrasonic sensor to the GND pin on the
ESP32.
- Connect the trigger pin of the ultrasonic sensor to a digital output pin on the
ESP32 (e.g., pin 23).
- Connect the echo pin of the ultrasonic sensor to a digital input pin on the ESP32
(e.g., pin 22).
Wiring Example:
--------------------------------
5V ---------- VCC
23 ---------- Trigger
22 ---------- Echo
Notes:
- Double-check the specifications of your ultrasonic sensor and match the pinouts
accordingly.
- Make sure the connections are secure, and there are no loose wires.
After making the connections, upload your code to the ESP32, open the Serial
Monitor in the Arduino IDE, and you should see distance measurements displayed
based on the readings from the ultrasonic sensor. The distance is measured in
centimeters.
29
CODE
#define TRIG_PIN 23
#define ECHO_PIN 22
float duration_us, distance_cm;
void setup() {
// begin serial port
Serial.begin (9600);
// configure the trigger pin to output mode
pinMode(TRIG_PIN, OUTPUT);
// configure the echo pin to input mode
pinMode(ECHO_PIN, INPUT);
}
void loop() {
// generate 10-microsecond pulse to TRIG pin
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// measure duration of pulse from ECHO pin
duration_us = pulseIn(ECHO_PIN, HIGH);
30
ESP 32 Motor controlling
Materials Needed:
- ESP32 Development Board
- L298N Motor Driver
- DC Motor
- Jumper Wires
- Breadboard
- Power Source (Battery Pack)
31
Step 2: Wiring
- Connect the wires from the ESP32 to the L298N motor driver:
- Connect GPIO pins 2, 4, 15, and 13 to the L298N inputs (IN1, IN2, IN3, IN4).
- Connect GPIO pins 5 and 14 to the L298N enable pins (ENA, ENB).
- Connect the motor to the L298N motor driver outputs (OUTA, OUTB).
32
const int motorAInput1 = 2;
const int motorAInput2 = 4;
const int motorBInput1 = 15;
const int motorBInput2 = 13;
const int enableA = 5;
const int enableB = 14;
void setup() {
pinMode(motorAInput1, OUTPUT);
pinMode(motorAInput2, OUTPUT);
pinMode(motorBInput1, OUTPUT);
pinMode(motorBInput2, OUTPUT);
pinMode(enableA, OUTPUT);
pinMode(enableB, OUTPUT);
Serial.begin(115200);
}
void loop() {
motorControl(enableA, motorAInput1, motorAInput2, 255);
delay(2000);
motorControl(enableA, motorAInput1, motorAInput2, 0);
delay(1000);
motorControl(enableB, motorBInput1, motorBInput2, 255);
delay(2000);
motorControl(enableB, motorBInput1, motorBInput2, 0);
delay(1000);
}
void motorControl(int enablePin, int input1, int input2, int speed) {
analogWrite(enablePin, speed);
digitalWrite(input1, HIGH);
digitalWrite(input2, LOW);
}
33
Step 4: Upload the Code
34