Robotics Module-1
L T P
LIST OF PRACTICALS
0 0 2
[Link] EXPERIMENT NAME
1. Blinking LED
Working of Different types of motors, switches and sensors
2
LDR based Automatic light control
3
4 Controlling brightness of LED using Potentiometer
5 Testing of IR sensors
6 Design of 2 Wheel wired Robot
To understand how to use the ADC facility in a microcontroller to convert analog
7
signals (e.g., from sensors) into digital values.
8 Interfacing SPST switch.
1|Page
Experiment No. 1
Object: Blinking LED
Hardware Required:
1. LED 5mm
2. Resistance 220 Ω
3. Arduino UNO Board
4. USB Cable
5. Arduino IDE
6. Laptop or PC (XP/7/8/10)
Circuit Diagram:
Code :
2|Page
After you build the circuit plug your Arduino or Genuino board into your computer, start the
Arduino Software (IDE) and enter the code below. You may also load it from the menu
File/Examples/[Link]/Blink . The first thing you do is to initialize LED_BUILTIN pin as an
output pin with the line
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Result: Successfully verifying the code for Blinking LED
3|Page
Experiment No. 2
Object: Working of Different types of motors, switches and sensors
H-Bridge Concept with explanation of L293 D & L298
S1 S2 S3 S4 Results
1 0 0 1 Motor move
right
0 1 1 0 Motor moves
left
0 0 0 0 Motor free runs
0 1 0 1 Motor brakes
1 0 1 0 Motor brakes
4|Page
It is an electronic circuit which enables a voltage to be applied across a load in either
direction.
It allows a circuit full control over a standard electric DC motor. That is, with an H-
bridge, a microcontroller, logic chip, or remote control can electronically command the
motor to go forward, reverse, brake, and coast.
H-bridges are available as integrated circuits, or can be built from discrete components.
A "double pole double throw" relay can generally achieve the same electrical
functionality as an H-bridge, but an H-bridge would be preferable where a smaller
physical size is needed, high speed switching, low driving voltage, or where the wearing
out of mechanical parts is undesirable.
The term "H-bridge" is derived from the typical graphical representation of such a circuit,
which is built with four switches, either solid-state (eg, L293/ L298) or mechanical (eg,
relays
Motor Driver ICs: L293/L293D and L298
5|Page
The current provided by the MCU is of the order of 5mA and that required by a motor is
~500mA. Hence, motor can’t be controlled directly by MCU and we need an interface
between the MCU and the motor.
A Motor Driver IC like L293D or L298 is used for this purpose which has two H-bridge
drivers. Hence, each IC can drive two motors.
Note that a motor driver does not amplify the current; it only acts as a switch (An H
bridge is nothing but 4 switches).
Drivers are enabled in pairs, with drivers 1 and 2 being enabled by the Enable pin. When
an enable input is high (logic 1 or +5V), the associated drivers are enabled and their
outputs are active and in phase with their inputs.
When the enable pin is low, the output is neither high nor low (disconnected),
irrespective of the input.
Direction of the motor is controlled by asserting one of the inputs to motor to be high
(logic 1) and the other to be low (logic 0).
To move the motor in opposite direction just interchange the logic applied to the two
inputs of the motors.
Asserting both inputs to logic high or logic low will stop the motor.
Resistance of our motors is about 26 ohms i.e. its short circuit current will be around.
0.46Amp which is below the maximum current limit.
It is always better to use high capacitance (~1000μF) in the output line of a motor driver
which acts as a small battery at times of current surges and hence improves battery life.
Difference between L293 and L293D:
Output current per channel = 1A for L293 and 600mA for L293D.
Difference between L293 and L298:
L293 is quadruple half-H driver while L298 is dual full-H driver, i.e, in L293 all four
input- output lines are independent while in L298, a half H driver cannot be used
independently, only full H driver has to be used.
Output current per channel = 1A for L293 and 2A for L298. Hence, heat sink is provided
in L298.
6|Page
Protective Diodes against back EMF are provided internally in L293D but must be
provided externally in L298.
Speed Control:
To control motor speed we can use pulse width modulation (PWM), applied to the enable
pins of L293 driver.
PWM is the scheme in which the duty cycle of a square wave output from the
microcontroller is varied to provide a varying average DC output.
What actually happens by applying a PWM pulse is that the motor is switched ON and
OFF at a given frequency. In this way, the motor reacts to the time average of the power
supply.
Result: Successfully study the use of motor driver and its working.
7|Page
Experiment No. 3
Object: LDR based Automatic light control
This is simple arduino project; turn on LED when it's dark and turn off when is light.
Hardware Required:
1. Arduino Uno
2. LED
3. LDR (photo resistor)
4. 220 and 10k ohm resistors
5. Wires
6. Breadboard
Circuit Diagram:
Code:
8|Page
const int ledPin = 13;
const int ldrPin = A0;
void setup() {
[Link](9600);
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
}
void loop() {
int ldrStatus = analogRead(ldrPin);
if (ldrStatus <=300) {
digitalWrite(ledPin, HIGH);
[Link]("LDR is DARK, LED is ON");
}
else {
digitalWrite(ledPin, LOW);
[Link]("---------------");
}
}
Result: Successfully implemented the circuit and verifying the code of LDR based automatic
street light controller.
9|Page
Experiment No. 4
Object: Controlling brightness of LED using Potentiometer
Hardware Required:
1. LED 5mm
2. Resistance 220 Ω
3. Arduino UNO Board
4. USB Cable
5. Arduino IDE
6. Laptop or PC (XP/7/8/10)
In placing the LED into the circuit, remember that you must always put the longer leg towards
the positive voltage. In the case above, the longer leg should be connected to the resistor, and the
shorter leg connected to ground. Also remember that we are using a 330 ohm resistor in the
circuit to limit the current through the LED.
The goal now is to use what you learned in the last three lessons. You will want to read a value
from the potentiometer, and then write a voltage to the LED based on the reading from the
potentiometer. Remember that when you read an analog voltage between 0 and 5 volts, the
arduino will report a number between 0 and 1023, with 0 representing 0 volts, and 1023
representing 5 volts.
Similarly, when you are writing an analog voltage between 0 and 5 volts, you must write a
number between 0 and 255. If you write a “0” value, that corresponds to 0 volts. If you write a
value of 255, that will output 5 volts. So, you must scale your write values between 0 and 255 to
get voltages between 0 and 5 volts.
The tricky thing now is that we want to dim the LED based on what value we read from the
potentiometer. If we read a 0 value from the potentiometer, we want to write a value of 0, which
corresponds to a voltage of 0. If we read a value of 1023 from the potentiometer, then we will
want to write our maximum voltage of 5 volts, which means we need to write a value of 255.
Basically, we need to scale our read values, which will be between 0 and 1023 to suitable write
values, which should be between 0 and 255.
10 | P a g e
Circuit Diagram:
Code:
const int analogPin = A0; //the analog input pin attach to analog pin A0
const int ledPin = 9; //the led attach to pin 9
int inputValue = 0; //variable to store the value coming from sensor
int outputValue = 0; //variable to store the output value
void setup()
{
}
void loop()
{
inputValue = analogRead(analogPin); //read the value from the sensor
outputValue = map(inputValue,0,1023,0,255); //Convert from 0-1023 proportional to the number of a
number of from 0 to 255
analogWrite(ledPin,outputValue); //turn the led on depend on the output value
}
Result: Successfully implemented and verifying the code of, controlling of brightness using
potentiometer
11 | P a g e
Experiment No. 5
Object: Testing of IR sensors
Requirement:
1. IR LED
2. Bread Board
3. Jumper wire
4. Power Supply
Because there is a semiconductor/chip inside the sensor, it must be powered with 3 - 5V to
function. Contrast this to photocells and FSRs where they act like resistors and thus can be
simply tested with a multimeter.
12 | P a g e
Here we will connect the detector as such:
Pin 1 is the output so we wire this to a visible LED and resistor
Pin 2 is ground
Pin 3 is VCC, connect to 3-5V
When the detector sees IR signal, it will pull the output low, turning on the LED - since the
LED is red its much easier for us to see than IR!
We will use 4xAA 1.5V batteries so that the voltage powering the sensor is about 6V. 2 batteries
(3V) is too little. You can also get 5V from a microcontroller like an Arduino if you have one
around. Ground goes to the middle pin.
The positive (longer) head of the Red LED connects to the +6V pin and the negative (shorter
lead) connects through a 200 to 1000 ohm resistor to the first pin on the IR sensor.
Now grab any remote control like for a TV, DVD, computer, etc. and point it at the detector
while pressing some buttons.
Result: Successfully study the use of IR sensor and its application
13 | P a g e
Experiment No. 6
Object: Design of 2 Wheel wired Robot
Requirement:
1. DPDT Switch
2. 2 DC Geared Motor 12 Volt
3. Wire
4. Battery 12 Volt or Power Supply
There are following tools are required for this project:
[Link] iron
[Link] saw/ blade
[Link] drivers
[Link]
[Link]
[Link] stripper
[Link]
[Link]
There are following components are required for this project-
Battery (12 volt , 4.5 Ah) - 1 nos.
DPDT Switch- 2nos. or 4 nos robot gripper
Ribbon wire strip- 3 meters+
DC Geared Motors 4nos 4x4 or 2 nos 4x2
Chassis(having holes for motor) - 1
box 1
Metal strip 12
Wheels 4 nos.
Castor wheel 1nos(4x2)
Soldering wire - as required
PAPER PLANNING:
Before you start making your robot you need a paper plan. Measure length of the motor
(excluding shaft), diameter of shaft of the motor, inner hole diameter of the motor. Draw a rough
sketch of the base you need to cut keeping in mind the placement of motors and wheels.
14 | P a g e
Chassis
Chassis is a mechanical assembly for making a 4 wheel drive [Link] you can mount any
controller board to drive your bot. This is just the mechanical chassis, Optionally as shown in the
figure you can use 4 DC geared motors, 1 castor and 4 wheels with rubber rings so you can make
both variants .
Mechanical assembly:
Fit the caster wheel at position show in above diagram with 1.5-2 inches (approx.) screw. Fit the
dc motor into the holes of chassis and couple the wheel by using screw or rubber tube.
What Is Caster Wheel
A Caster wheel is an undriven, single wheel that is designed to be mounted to the bottom of a
larger object so as to enable that object to be easily moved. They are available in various sizes,
and are commonly made of rubber, plastic, nylon, aluminum, or stainless steel, etc.
15 | P a g e
DPDT Switches Using Circuit
To make anti-clockwise motion of motor, the polarity of supply must be inverted of polarity of
supply in clockwise motion. For "Polarity Reversal" DPDT switches are generally used. This can
be done by using following circuit.
DPDT Switch Connections for wired control
the wire should solder on metal strip not on switches directly. This precaution helps us if there is
wrong connection occurs in circuit. So we can change the circuit by changing metal strip
position. The procedure is shown in figure below-
Motor Connections
The rechargeable battery of rating 12 Volt and 4.5 ampere rating should connected with remote
switch and ...you can 9v ! 8 pcs AA battery (12V) holder with on/off switch.
16 | P a g e
The above circuit shows you how to connect the dpdt switchs to the motors and the 12V supply
and by pressing the switch you can check the direction of the robot and change it accordingly.
thus you are ready with your first WIRED ROBOT
Result: Successfully implemented 2 Wheel robot.
17 | P a g e
Experiment No. 7
Objective:
To understand how to use the ADC facility in a microcontroller to convert analog signals (e.g.,
from sensors) into digital values.
Components Required:
1. Microcontroller (e.g., Arduino, PIC, STM32, etc.)
2. Potentiometer or any analog sensor (like temperature or light sensor)
3. Jumper wires
4. Breadboard
5. Power supply (5V or 3.3V depending on the microcontroller)
6. Multimeter (optional, for measuring analog voltage)
Theory:
Most microcontrollers come equipped with an ADC module, which converts an analog voltage
(usually between 0V and the reference voltage, e.g., 5V or 3.3V) into a digital value. The
resolution of the ADC (e.g., 10-bit, 12-bit) determines how many discrete digital values can
represent the input voltage.
Resolution: A 10-bit ADC can produce values between 0 and 1023 (210 - 1).
Reference Voltage (V_ref): The maximum voltage that corresponds to the maximum
digital value (e.g., 1023 for a 10-bit ADC).
Circuit Diagram:
1. Connect the middle pin of the potentiometer to the analog input pin (e.g., A0) of the
microcontroller.
2. Connect one side of the potentiometer to Vcc (5V or 3.3V).
3. Connect the other side of the potentiometer to GND.
4. Connect the microcontroller to the power supply.
Steps:
1. Set up the microcontroller and IDE:
a. Use a development board like Arduino (with Arduino IDE), or STM32 (with
STM32CubeIDE).
b. Choose the correct board and port in the IDE.
18 | P a g e
2. Write the code: Here's an example of how to set up and read the ADC value in Arduino:
#define pot A0
void setup()
{
pinMode(pot,INPUT);
[Link](9600);
}
void loop(){
int val=analogRead(pot);
[Link](val);}
1. Upload the code:
a. Compile and upload the code to the microcontroller using the IDE.
b. Open the Serial Monitor (if using Arduino) to view the ADC readings and
corresponding voltage.
2. Observation:
a. Rotate the potentiometer or change the analog sensor's input.
b. The ADC value and voltage should vary as per the input. For example, if you are
using a 5V reference and a 10-bit ADC, the value should range between 0 (0V) to
1023 (5V).
3. Calculate the voltage manually (optional): You can verify the voltage by using a multimeter
to measure the actual analog voltage across the input pin.
Result:
We will be able to read the analog voltage and convert it into a digital value using the ADC
facility of the microcontroller. The values will vary based on the analog input from the sensor.
19 | P a g e
Experiment No. 8
Objective:
To understand the working of a Single Pole Single Throw (SPST) switch and interface it with a
microcontroller to control an output device (e.g., LED).
Apparatus Required:
1. SPST Switch
2. Microcontroller (e.g., Arduino, Raspberry Pi, or any other development board)
3. Breadboard
4. Connecting wires
5. Resistor (1kΩ)
6. LED
7. Power supply (5V DC)
Theory:
An SPST (Single Pole Single Throw) switch is a basic on-off switch. It allows or interrupts the
flow of current in a circuit. When connected to a microcontroller, it can act as an input device to
control outputs like LEDs, motors, or other actuators.
Circuit Diagram:
Create a simple circuit where:
1. One terminal of the SPST switch is connected to the microcontroller's input pin.
2. The other terminal of the switch is connected to a pull-down resistor (1kΩ) and ground.
3. Connect the LED to another pin of the microcontroller through a resistor (220Ω).
Procedure:
Hardware Setup:
1. Place the SPST switch on the breadboard.
2. Connect one terminal of the switch to the microcontroller’s digital input pin (e.g., Pin 2
for Arduino).
3. Connect a 1kΩ pull-down resistor between the input pin and ground to avoid floating
values.
4. Connect the other terminal of the switch to the 5V supply.
5. Connect the LED to the microcontroller’s digital output pin (e.g., Pin 13 for Arduino)
through a 220Ω resistor.
20 | P a g e
Software Setup:
1. Write the following code to detect the switch state and control the LED.
Sample Arduino Code:
int switchPin = 2; // SPST switch connected to digital pin 2
int ledPin = 13; // LED connected to digital pin 13
int switchState = 0; // Variable to store switch state
void setup() {
pinMode(switchPin, INPUT); // Set the switch pin as input
pinMode(ledPin, OUTPUT); // Set the LED pin as output
[Link](9600); // Initialize serial communication for debugging
void loop() {
switchState = digitalRead(switchPin); // Read the state of the switch
if (switchState == HIGH) { // If the switch is pressed
digitalWrite(ledPin, HIGH); // Turn ON the LED
[Link]("Switch ON");
} else {
digitalWrite(ledPin, LOW); // Turn OFF the LED
[Link]("Switch OFF");
delay(100); // Small delay to debounce the switch
21 | P a g e
Observation:
Switch State LED State Serial Monitor Output
Pressed (HIGH) ON "Switch ON"
Released (LOW) OFF "Switch OFF"
Result:
Successfully completed interfacing SPST switch.
22 | P a g e