0% found this document useful (0 votes)
4 views

Electronics lab (3)(updated) (2)

The project report details the development of a 'Wireless Hand Gesture Controlled Robotic Arm and Vehicle' designed for pick and place operations, aimed at aiding individuals with disabilities. It outlines the components used, including Arduino boards, sensors, and motors, and discusses the applications in defense, industry, and medical fields. The report emphasizes the significance of robotics in enhancing efficiency and safety in various tasks while providing a comprehensive overview of the project's construction and implementation.

Uploaded by

Aashri Bansal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Electronics lab (3)(updated) (2)

The project report details the development of a 'Wireless Hand Gesture Controlled Robotic Arm and Vehicle' designed for pick and place operations, aimed at aiding individuals with disabilities. It outlines the components used, including Arduino boards, sensors, and motors, and discusses the applications in defense, industry, and medical fields. The report emphasizes the significance of robotics in enhancing efficiency and safety in various tasks while providing a comprehensive overview of the project's construction and implementation.

Uploaded by

Aashri Bansal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 66

Wireless Hand Gesture controlled Robotic

Arm and Vehicle for pick and place


operations

A Project Report by “THE


ANONYMOUS”
ADVANCED ELECTRONICS LAB-II (PHYS 534)- 2020

DEPARTMENT OF PHYSICS AND ASTROPHYSICS | UNIVERSITY OF DELHI 110007


GROUP MEMBERS
 Aashri Bansal (1887197)
 Swati Goyal (1887185)
 Jatinder Pal Singh (1887018)
 Manish Kumar(1887027)
 Kritika Sharma(1887102)
 Manjeet (1887104)

1
Aashri Bansal Swati Goyal

Manish Kumar Jatinder Pal Singh

Manjeet Kritika Sharma

2
DECLARATION

We hereby declare that the project entitled “Wireless Hand gesture controlled
Robotic Arm and Vehicle for Pick and place operations” is based on our work
carried out during the course (January 2020 to May 2020) in Masters in Physics
submitted at the Department of Physics and Astrophysics, University of Delhi.
We assert that the conclusions drawn and work done are an outcome of our
work. The work has not been submitted to any other Institution for any other
degree/certificate in this University or any other University.

Whenever we have used theoretical analysis and text from other sources, we
have given due credit to them and giving their details in the references.

Date: 15th June 2020

ACKNOWLEDGEMENT
3
We would like to this opportunity to acknowledge the support of all those
without whom this project report would not have been possible.

In the accomplishment of our project we “THE ANONYMOUS” group


members would like to thank all the people who have been involved in this
project. We would like to thank all the people who have been concerned with
this project. We would like to express our special thanks of gratitude to our
teachers (Prof. Nivedita Deo, Prof. Vinay Gupta, Prof. Amitabha Mukherjee,
Prof. K Sreenivas) who have helped us to put into great ideas. Every time when
we reached the, with our difficulties they welcomed them, which helped us in
completing the project successfully.

We would also like to thank our lab assistants for their generous attitude and
friendly behaviour.

We would also like to thank the Solid-State lab attendants for giving access to
various instrumentations.

At last, we would thank each other as fellow lab-mates, for the stimulating
discussions for the completion of the project within limited time.

4
Table of Contents

INTRODUCTION................................................................................................9
DESCRIPTION OF THE COMPONENTS USED...................................................11
THEORY.......................................................................................................... 24
CONSTRUCTION..............................................................................................29
Robotic Vehicle...........................................................................................29
Robotic Arm................................................................................................31
CIRCUIT SCHEMATICS.....................................................................................34
WORKING.......................................................................................................38
Robotic Vehicle...........................................................................................38
Robotic Arm................................................................................................41
DESCRIPTION OF SOURCE CODE.....................................................................46
Robotic Vehicle...........................................................................................46
Robotic Arm................................................................................................54
IMPLEMENTATION.........................................................................................61
PROPOSED PLAN OF ACTION FOR PARTS THAT WERE NOT TESTED...............62
CONCLUSIONS................................................................................................63
FUTURE SCOPE...............................................................................................64
REFERENCES...................................................................................................66
APPENDIX.......................................................................................................67

5
6
INTRODUCTION

Our objective for this project was to design hardware and software for
“Wireless Hand gesture controlled Robotic Arm and vehicle for pick and
place operations”

The word robot was coined by a Czech novelist Karel Capek in 1920. Robot in
Czech is a word for worker or servant. In another words, it can be defined as
any automatically operated machine that replaces human effort.

Robots are widely used in such industries as automobile manufacture to perform


simple repetitive task, and in industries where work must be performed in
environments hazardous to humans.

Robotics is a current emerging technology in the field of science. A number of


researchers are working in this field. Robotics is the new emerging field, which
will be of great use to society in the coming years. These days many types of
wireless robots are being developed and are put to varied applications and uses.

Here, an effort has been made to developed a hand gesture based robotic car and
a robotic arm which will pick and place the objects from the car. The robotic car
is operated and controlled wirelessly with the help of hand gestures which
transmits signals to the car through an auto device which is fixed on the gloves
or can say that the user just needs to carry a gesture device which in our case is
transmitter section. The car moves and acts in the manner depending on the
gestures made by the fingers and hand from a distance. The car can move in
forward, backward direction according to our hand’s orientation. The robotic
arm which is mounted on the car, can pick the objects from ground and can
place it in the car, this signature is followed according to the movements of
fingers and hand. It is basically servo controlled robotics system.

Hand gesture based robotic vehicle mainly benefits in the condition where
disabled persons can’t drive the vehicle itself, in this condition they can move
the vehicle in the direction they want to go with the help of the hand gestures.

7
And the Robotic arm mainly benefits for places where there is a need to pick an
object and place it to some other place safely. If the object is being picked by
the human, there is a risk of damage to the object which is avoided by this
system.

This system includes mainly two sections:

Robotic Glove: It consists MPU 6050, Flex sensor, RF Module 433 MHz transmitter, Arduino Nano

Robotic Vehicle: It consists DC Motors, Servo Motors, RF Module 433 MHz receiver, Arduino Uno

These different components are defined later.

APPLICATIONS:

Practical Applications of Gesture controlled Vehicle:

 Hand gesture controlled vehicle can be used by physically challenged in


wheelchairs.

Practical Applications of Pick and Place Robot:

 Defence Applications: It can be used for surveillance and also to pick


up harmful objects like bombs and diffuse them safely.
 Industrial Applications: These robots are used in manufacturing, to pick
up the required parts and place it in correct position to complete the
machinery fixture. It can also be used to place objects on the conveyer
belt as well as pick up defective products from the conveyer belt.
 Medical Applications: These robots can be used in various surgical
operations like in joint replacement operations, orthopaedic and internal
surgery operations. It performs the operations with more precision and
accuracy.

8
DESCRIPTION OF THE COMPONENTS
USED

 Arduino Uno
 Arduino Nano
 MPU6050 (Gyroscope + Accelerometer + Temperature) Sensor Module
 Flex Sensor
 Servo Motor
 RF Module 433 MHz Transmitter-Receiver pair
 DC motors

ARDUINO UNO

Open-source platform which means the boards and software are readily
available. The software for Arduino devices is called Integrated Development
Environment(IDE) and is free to use. We can use C and C++ as programming
languages.

 It is a microcontroller board which is based on the ATmega328


microcontroller’s series. Various sensors will forward the environmental
data as an input it which will send the attached peripherals.
 It contains total of 28 pins of which 14 digital I/O pins (six are pulse
width modulation (PWM) pins) and 6(six) pins are analog which can be
used for interaction sensor, motors;3 GND pins (for grounding) and
remaining pins are for 3.3V, 5V, Vin, RESET and AREF.
 It has a microcontroller with a storage of 32 KB memory, 2KB SRAM
and 1KB of EEPROM.
 5V is required to turn it on which can be directly taken from USB port.

9
Description of pins:

Pin type Pin name Details


Power Vin, 3.3V, 5V,GND Vin: Input voltage to Arduino when
using an external power source.
5V: Regulated power supply used to
power microcontroller and other
components on the board.
3.3V: 3.3V supply generated by on-
board voltage regulator. Maximum
current drawn is 50mA.
GND: ground pins.
Reset Reset Resets the microcontroller
Analog pins A0-A5 Used to provide analog input in the
range of 0-5V.
Input/ Digital pins 0-13 Can be used as input or ouput pins.
Output pins
Serial 0(Rx), 1(Tx) Used to receive and transmit TTL
serial data.
External 2,3 To trigger an interrupt
Interrupts
PWM 3,5,6,9,11 Provides 8-bit PWM output.
SPI 10(SS), 11(MOSI), Used for SPI communication.
12(MISO) and
13(SCK)
Inbuilt LED 13 To turn on the inbuilt LED
TWI A4 (SDA), A5(SCA) Used for TWI communication.
AREF AREF To provide the reference voltage for
input voltage.

10
Following figure shows the Arduino Uno board:

ARDUINO NANO

The Arduino Nano is a small, complete, and breadboard-friendly board based


on the ATmega328 (Arduino Nano 3.x). It has more or less the same
functionality of the Arduino Uno. It lacks only a DC power jack, and works
with a Mini-B USB cable instead of a standard one.

 It contains 30 pins of which 14 are digital input and output pins (6 are
PWM), 8 analog pins, 2 GND pins, 2 RESET and remaining pins for 5V,
3V, Vin and REF.

Following figure shows the pinout of the Arduino Nano board:

11
FLEX SENSOR

It is actually a strip of carbon material with metal pads inside it. This is
basically a sensor which measures the amount of bending or deflection. When
the strip is bend or deflect then the resistance of this flex sensor is changed
therefore it is also called bend sensor.

The following figure shows the image of flex sensor:

This resistance was calibrated and converted into angles according to our needs
and further used for the pick and placing purpose in the Robotic Arm.

Working Principle of Flex Sensor

This sensor works on the principle of bending. As the sensor is bended, the
resistance across the sensor increases. It means when the strip is bend then its
resistance is changed which can be measured with the help of controller. This
change will depend upon the surface linearity or can say depend upon the
amount of bending done.

The next figure shows the change in resistance with respect to different angles:

12
Flat (nominal resistance)

45⁰ Bend (increased resistance)

90⁰ Bend (resistance increased further)

So the resistance across the terminals rises linearly with bent angle. So in a
sense the flex sensor converts flex angle to RESISTANCE parameter.

Flex Sensor Pin Configuration:

Flex sensor is a two terminal device. The flex sensor does not have polarized
terminals like diode. So there is no positive and negative.

Pin Number Description


P1 Usually connected to positive of power source
P2 Usually connected to ground

How to interface Flex sensor with Arduino Board?

For measuring bend, flex sensor is used with type of controller such as
microcontroller or Arduino etc. Here we are discussing how we can interface it
with Arduino board. For interfacing with Arduino board this sensor is powered
up with Arduino board. When it is connected with Arduino board then its pin1
is connected to +5V Arduino board pin through 100K ohm resistor and pin 2 is
directly connected to Arduino ground pin. Similarly, a wire is connected
between the centre point of 100k ohm resistor and flex sensor to Arduino board
A0 pin. For check purposes, a led is connected to the PWM on Arduino board
as shown in figure

13
MPU6050 MODULE

The MPU-6050 sensor holds a MEMS (Micro-Electro-Mechanical Systems)


accelerometer and a MEMS gyroscope only in the single chip.

 MPU-6050 has 16-bits analog to digital conversion hardware for each of


the channels.
 MPU-6050 interfaces with the Arduino microcontroller using I2C
protocol.
 It consists of 8 pins.
 It operates at 3V-5V.
 It has In-built Temperature sensor.
 It has built-in DMP which provides high computational power.
 It can be used to interface with other I2C devices like magnetometer

Pin Name Pin Function


VCC For providing power
Ground For grounding of system
Serial Clock (SCL) SCL used for providing clock pulse for I2C
communication
Serial Data (SDA) SDA used for transferring data through I2C
communication

14
Auxiliary Serial Data (XDA) XDA is optional but can be used to interface
other I2C modules with MPU6050
Auxiliary Serial Clock (XCL) XCL is also optional but can be used to
interface other I2C modules with MPU6050
AD0 If more than one MPU6050 is used a single
MCU, then this pin can be used to vary the
address
Interrupt pin (INT) It indicated that data is available for MCU to
read

The following figure show the different pins of MPU-6050 Module:

RF MODULE 433 MHz TRANSMITTER-RECEIVER PAIR

RF modules are 433 MHz RF transmitter and receiver modules that are used to
transmit and receive the infrared waves.

 Its working voltage is between 3V-12V and consumes 12V power.


 RF transmitter can transmit up to 90m in open area.

RF Transmitter consists of three pins:

Pin Name Pin Function


ATAD Signal pin used to send data for the receiver
VCC For providing voltage
Ground Pin For grounding the module

 RF receiver working voltage is 5V.

15
RF Receiver consists of four pins:

Pin Name Pin Function


VCC For providing voltage
Two DATA pins To receive data from transmitter
Ground For grounding the module

The following image shows the RF transmitter- receiver pair:

SERVO MOTOR

A servo motor is an electrical device which can push or rotate an object. If we


want to rotate the object at some specific angles or distance, then we can use
servo motors.

 A servo motor consists of three wires- a black wire connected to the


ground ,a white/yellow wire connected to control unit, a red wire
connected to the power supply
 The function of the servo motor is to receive a control signal that
represents a desired output position of the servo shaft and apply power to
its DC motor until its shaft turns to that position.
 Servo motor generally requires a DC supply of 4.8-6V.

16
The image below given the description of the servo motor:

DC MOTOR

 A DC motor is a class of rotary electrical motors.


 It converts direct current electrical energy into mechanical energy.
 Speed of motor is counted in terms of rotations of the shaft per minute
and is termed as RPM.
 DC motor's speed can be controlled either by a variable supply voltage or
by changing the field windings.

Image of the DC motor is shown below:

17
Controlling of Motor with Arduino and transistor:

Connection of DC motor with Arduino

 The current provided by the PWM pins of the Arduino that can be used to
control the speed of the DC motor is less than that required by the motor.
 So, a transistor as an amplifier is used as an intermediator between the
DC motor and the Arduino with the Arduino PWM pin connected to the
base pin of transistor to make sure the PWM pins can control the speed of
the motor.

18
CONSTRUCTION
Robotic Vehicle

The design of the vehicle was created by keeping in mind to maximize the
mobility of the whole structure to provide stability and appreciable speed while
movement. One way to achieve this was to keep the vehicle as light-weight as
possible, so the material used to construct the vehicle was chosen appropriately.
The design of the vehicle base (dorsal view) is shown below:

A rear wheel drive was opted of the vehicle design with the front wheel
handling the turning of the vehicle. This was initially done believing this design
will provide good traction and stability and improving and modifying on the

19
same during the experimental phase if any problems were faced. The vehicle
also needed to have space to mount the robotic arm. The overall design of the
vehicle (lateral view) is shown in the next figure.

To construct the base, a thick electric switch-board of poly-carbonate


(approximately 24cm X16cm in dimensions) was taken. The choice of the
material was on the basis of its strength and it being light-weight at the same.
Cuts were made on side of the board which will eventually become the rear side
of dimensions 9 cm X 2 cm to accommodate rear wheels making sure they have
enough space to rotate. In the front side the cut was of length 9 cm and width
4.5 cm. As the front wheels were going to control the turning, enough space was
provided for lateral movement. (this movement is later verified in the
experimental section).

A pair of DC Motor was then connected to the rear wheels and front wheels
were supported by and axle connected to a servo motor. After construction, the
vehicle looked like the next figure.

20
All wires of motors and servo motor were later connected to Arduino UNO
which also housed RF receiver, and is placed in between space of front and rear
wheels.

Robotic Arm

The design of a robotic or mechanical arm depends solely on its application and
there and hundreds of ways to design one depending on the axes available for
rotation and movement, degrees of freedom and a total of fourteen such
parameters.

As the main application of the arm in this project was going to be pick and place
operation, a design based on Selective Compliance Articulated Robot Arm
design was used as shown in the next figure.

The links in the arms connected by rotary joints are what provide the robot an
axis for rotation providing it an additional degree of freedom, or range of
motion.

21
It is a known fact that at least two different axes are required to reach any point
in space. So, two joints were chosen in the design leading to four degrees of
freedom. The arm itself is only responsible for positioning. An end effector is
necessary for actual environment interaction. This was achieved by the gripper
at the end which facilitate pick and drop operations.

For construction, to make space to put the whole robotic arm (or the base of
robotic arm) on vehicle, the electric switch board of same dimensions as the
base of vehicle was taken and to hold it with the base of car, 4 long boults were
used.

For left and right movement at the base, a smaller board is connected to the base
of the arm by a heavy servo motor.

To make the arm, electric rectangular shape fitting pipes, made out of Polyvinyl
Chloride were used, as they are again light-weight and sturdy. Firstly, a piece of
pipe was inclined with movable base with the help of nail and a servo motor in
its end to move the arm up and down (as shown in the next figure)

22
Now to make the next part, we used same type of pipe whose one end is
connected to servo motor’s shaft.

And to handle pick and drop operations, we made a handle out of hard-
cardboard which has movable joints, each connected with individual servo
motor and both of them receive the same input signal so they open and close in
synchronisation.

All the wires of servo motors were connected with Arduino UNO with RF
receiver which was placed on the top part of the vehicle.

Left is the picture of arm with handle

23
CIRCUIT SCHEMATICS

With the design and basic structure of the project ready, the next step in the
procedure is to connect the circuit components as required. Just like the last
section, this section is also divided into the circuits for the vehicle and the robot
arm. Further, they are divided into the transmitter section and receiver section
for both.

Robotic vehicle

Transmitter section:

The circuit for the transmitter section of the vehicle is as shown below. It will
be placed on a glove which will be worn by the user to control the vehicle.

The circuit comprises of an MPU6050 sensor connected to the Arduino nano.


The SDA and SCL pins of the sensor are connected to the corresponding pins of
the Arduino i.e. A4 (SDA) and A5 (SCL). To transmit the data, the RF-433
transmitter is connected to the D12 pin of the Arduino, as required by the
header file specification that helps in the interfacing of the RF transmitter and
Arduino.

24
Receiver section:

The circuit for the receiver is shown below. It will be placed on the vehicle as
discussed in the last section and will be connected to the components of the
vehicle.

The RF-433 receiver is connected to Arduino Uno’s pin 11 as defined by its


header file. The DC motor driving the rear wheels is connected to Digital pin 5
of the Arduino, which is one of the PWM controlled pin, this is required to
control the speed of the motor and thus, the vehicle. The servo motor
controlling the front wheels is connected to another PWM pin, Digital 10 and

25
the power and ground pins of all components is also connected to the required
Arduino terminals.

Robotic arm

Transmitter section:

Just like the vehicle, the transmitter circuit for the robotic arm will also be
placed on a glove worn by the user to control its movements. The circuit is as
shown below:

The connections of the MPU6050 sensor and the RF-433 transmitter is the same
as discussed in the last section. An extra circuit element here is the flex sensor,
the voltage across which is measures using the A0 pin of the Arduino Nano,
which helps in analog measurements. A 10k resistor connected in series with
the flex sensor acts as a voltage divider for the 5V source. As the bending of the
flex sensor is changed, its resistance changes and the voltage across it varies
accordingly. This will be used to control the opening and closing of the gripper
of the arm.

26
Receiver section:

The receiver section controls the robotic arm. To do so, Arduino Uno is placed
on the top of the vehicle and is connected to the different components of the
robotic arm as mentioned in the previous section. The circuit is as shown below:

The RF-433 receiver is connected to the D11 pin of the Arduino Uno as
explained in the receiver section of the vehicle. The power and ground pins of
the array of Servo motors is connected to the 5V and ground terminals of the
Uno. Now, the controller pin of different motors is connected to different PWM
pins of the Arduino. The motor at base of the arm is connected to pin D5, the
motor at the joint is connected to pin D6 while the two motors the constitute the
gripper are connected to pins D9 and D10. This concludes all the circuits used
in the project

WORKING
27
Robotic Vehicle

The heart behind the working of this vehicle is the MPU6050 teamed up with
the Arduino microcontroller.

As discussed earlier, MPU6050 can be used as a GYROSCOPE,


ACCELEROMETER and TEMPERATURE sensor.

Here, for our purpose, the accelerometer feature of the sensor was enough to
handle all movements and the gyroscope feature which measures angular
velocity was not requires. The accelerometer gives us the amount of force(i.e.
acceleration) experienced by the sensor in X,Y,Z direction. For example, if
there is an MPU6050 placed on your hand and just hold your hand straight then
it will give you z-component of acceleration (i.e. AZ), +1g where g is
acceleration due to gravity and other components (i.e. Ax, AY) wii be be zero.
Now, if we tilt or move our hand in up-down or right-left direction, then it will
distribute the acceleration due to gravity along different directions depending on
the angle of tilt as discussed in the theory, giving us the component of
acceleration in x, y and z direction also and after using all these components ,
we drive formulas of roll and pitch as

Pitch = 180 × atan(Ax/sqrt(Ay*Ay + Az*Az))/π;


Roll = 180 ×atan (Ay/sqrt(Ax*Ax + Az*Az))/π;

At the moment, these are just raw values and do not mean anything. We assign
different operations to different movements of our hand to control the vehicle as
shown in the figure below. This will completely take care of all the motion of
the vehicle.

28
DIAGRAM ILLUSTRATING THE HAND GESTURES TO CONTROLTHE
MOTION OF THE VEHICLE

Once we obtain the different values of pitch and roll for different orientations of
our hand, our next task is to transmit these values to the vehicle which is done
by RF module transmitter-receiver pair. The transmitting part is given with the
flow of control is as shown below:

29
In the receiver part of the vehicle, we use the roll values to control the two DC
motors which are connected to the rear wheels of vehicle and pitch value is used
to control the servo motor, which is connected to front two wheels of the
vehicle so that we can turn our vehicle in left-right direction. Block diagram for
receiver part with flow of control is given below:

Shown below is the Original picture of the base of robotic vehicle


constructed by us.

30
The two DC motors are connected to the rear wheels and a servo motor is
connected to front two wheels will move our vehicle to right or left
depending upon our hand orientation and all these motions were verified
by us.

Robotic Arm

Now, our next task was to operate the robotic arm which is placed on our
vehicle. We will use our second hand to operate the movements of the robotic
arm. Here, we will use the MPU6050 sensor which will control the motion of
our robotic arm along with a flex sensor used to close and open the grip of the
robotic arm. An RF module transmitter-receiver pair is used to send data form
hand to arm just like the last part and of course, Arduino at both, transmitting
and receiving part to control the whole operation.

On left is the original picture of the


robotic arm mounted on the robotic
vehicle constructed by us.

31
OUR ROBOTIC ARM

As discussed above, the MPU6050 (which is placed on our hand) readings, we


can be converted in pitch and roll values. And from flex sensor (which is placed
on one of our fingers), we can change the value of resistance or voltage drop
across resistor on flex sensor, by bending it .So, by rotating our hand or
bending our finger ,we will use robotic arm to pick and drop the object,
anywhere we want.

32
ZOOMED VIEW OF OUR GRIPPER

The control flow of transmitting part is given below:

33
This is the picture of the second hand to control the robotic arm which we
we would have verified if time has permitted us.

In the receiver part, we used a heavy servo motor (Tower Pro MG995), on
which we place the whole base of robotic arm so that our robotic arm can move
in left or right direction, one light servo motor (Tower Pro SG90, let’s call it
servo 1) to move our robotic arm up – down and 2 more light servo motors
(same, Tower Pro SG90 , let’s call them servo 2 and servo 3), to make a gripper
of robotic arm to pick and drop the things.

So, we provide roll values to servo 1 and pitch values to heavy servo motor and
value from flex sensor, will be used for servo 2 and servo 3.

How the whole arm moves depending on the roll and pitch values will be
controlled by the coding and is described in detail in the next section.
In the programming, we set only two values for operating flex sensor: one is to
open the handle and second one is to close it.
In normal position, it is in open state.

Block diagram with flow of control for receiver part is given below:

34
NOTE: Robotic arm shown in above picture is also constructed by us .

35
DESCRIPTION OF SOURCE CODE

With all the hardware connected together, it all comes down to coding with the
task to make sure all the hardware pieces are interfaced properly and work as a
unit to perform the task they are supposed to. As Arduino is the microcontroller
used in the project both at the transmitter and receiver section, it is the heart of
the whole project and the programming is thus written, executed and uploaded
to use in the project using the official Arduino Interactive Development
Environment (IDE).

Robotic Vehicle

Transmitter section
The transmitter section for both the vehicle and the robotic arm perform almost
in the same way. As both of them use the MPU6050 Accelerometer-Gyroscope
sensor along with the RF Transmitter to transmit data, one of the initial tasks at
hand is to make sure both these devices are connected properly to the Arduino
following all the correct protocols. Let’s analyse the code part by part:

//Transmitter
#include<Wire.h>
#include <RH_ASK.h>
#include <SPI.h>

The MPU6050 supports only I2C Communication and hence, it must be


connected only to the I2C Pins of the Arduino. The I2C pins of Arduino are
multiplexed with the analog input pins A4 and A5 i.e. A4 is SDA and A5 is
SCL. The Wire Library is used to obtain the data from the MPU6050
Accelerometer-Gyroscope. The Wire library facilitates I2C communication with
the MPU6050 using the SDA and SCL pins of the Arduino.

36
The RadioHead (RH_ASK) library provides a complete object-oriented library
for sending and receiving packetized messages via a variety of common data
radios and other transports on a range of embedded microprocessors. Thus, it
helps in the wireless transfer of data via the RF transmitter.

The Serial Peripheral Interface (SPI) Library, although not directly used in the
program, is essential for the synchronous serial data protocol used by
microcontrollers for communicating with one or more peripheral devices
quickly over short distances.

RH_ASK driver;
float roll,pitch;
const int MPU6050_addr=0x68;
int Angle[2];
float AccX,AccY,AccZ,Temp,GyroX,GyroY,GyroZ;

Now we move on to declaration of variables and objects at the global scale.


First, we declare an object of RH_ASK class named driver that will facilitate
the wireless transmission. Then we declare a constant with the address of the
MPU6050 sensor as the I2C protocol demands. The rest are variables which
will be used to store data from the sensor and transmit the data when the
program runs.

void setup()
{ Wire.begin();
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}

In the setup() section, we initialise our transmission procedure. This is done first
by calling the begin()function from the Wire library. Then as per the defined
protocols we first feed the MPU6050’s address and then wake up the 0x6B
register, which is essential to start transmission.

37
The Wire.endTransmission(true)just makes sure that the transmission is started
from the beginning when the due protocols are done with. In the last line, the if
(!driver.init()) just make sure if the RF transmitter is working properly and
displays the message if it is not. With the communication setup and everything
working, it is time to collect and transmit data.

void loop()
{
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU6050_addr,14,true);
float Acc[] = {0,0,0};

The code in the loop() part is executed over and over, and must contain the task
we want to perform. Once we feed the feed the MPU6050’s address, we begin
the data retrieval from the 0x3B register, which actually stores the acceleration
along the x direction. The MPU6050 Accelerometer-Gyroscope gives seven
values at a time. They are: Acceleration along the x, y, z axis, the temperature
and Angular velocity along the x, y, z axis, stored in the register in the same
order, with each value occupying 16 bits or 2 bytes. The
Wire.requestFrom(MPU6050_addr,14,true) function asks the MPU6050 sensor
to send data, beginning from the register mentioned earlier (0x3B) and stopping
after 2X7=14 bytes.

Acc[0]=Wire.read()<<8|Wire.read();
Acc[1]=Wire.read()<<8|Wire.read();
Acc[2]=Wire.read()<<8|Wire.read();
Temp=Wire.read()<<8|Wire.read();
GyroX=Wire.read()<<8|Wire.read();
GyroY=Wire.read()<<8|Wire.read();
GyroZ=Wire.read()<<8|Wire.read();

Once the transmission begins, we need to store the incoming data into variables.
The data is transferred to Arduino byte by byte but every value is of two byte
and we need to merge those incoming bytes to make sense of the data. This is
done using the lines of code above.

38
As soon as data is received by using Wire.read(), the operator <<8 shifts the
data by 8 bits on the left-hand side. After the function Wire.read() reads the next
8 bits and the | operator makes sure the two of them are merged to form the
required 16 bit data.

The array Acc stores the acceleration along the x, y and z direction. Other
values are also stored (just to check if the data transfer is working smoothly) but
are not used further in the program.

Acc[0]/=16383; Acc[1]/=16383; Acc[2]/=16383;


roll = atan(Acc[1] / sqrt(pow(Acc[0], 2) + pow(Acc[2], 2))) * 180 / PI;
pitch = atan(-1 * Acc[0] / sqrt(pow(Acc[1], 2) + pow(Acc[2], 2))) * 180/PI;
Serial.print("Roll="); Serial.print(roll);
Serial.print(" || Pitch="); Serial.println(pitch);

Angle[0]=int(round(roll));
Angle[1]=int(round(pitch));

The raw data that we receive is in the for of a number ranging from 0 to 16383
(216-1) as it is 16-bit data. But in order to covert that into angular tilt, we need to
convert it into the respective g (acceleration due to gravity) values, which varies
from 0 to 1 g in magnitude. So, we divide the data we receive by 16383 to do
so. Then, these values are substituted in the formula for roll and pitch as
discussed earlier. Finally, the roll and pitch are transferred to a new array called
Angle.

driver.send((uint8_t *)Angle, 4);


driver.waitPacketSent();
delay(500);
}

With the data ready, it is time to transmit it. The driver.send(() function sends
the data over the RF transmitter. uint8_t * makes sure that the data is of the
format as required by the transmitter. 2X2=4 is the size of the total data being
transmitted i.e. the Angle array.
The driver.waitPacketSent() makes sure the data packets are delivered properly
and a delay is introduced so all the processes run smoothly.

39
Receiver section

Once the data is transmitted by the RF transmitter, the RF receiver catches it


and now the job is to decode those raw bytes into meaningful data and once that
is done, the servo motor and DC motors operate as described in the Working
section of the report.

//Receiver

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#include <Servo.h>

Just like the Transmitter section, the RadioHead(RH_ASK) library is used is


facilitate wireless communication between the transmitter and receiver. The
Servo library is used to control the Servo motor by creating objects of the Servo
class.

RH_ASK driver;
int motor=5;
int spd=0;
int Angle[2];
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position

The RH_ASK objects helps in retrieving data from the receiver. The myservo
object of Servo class is for the movement of servo motor. The rest of the
variables store the data and the pins at which the motors are attached to.

void setup()
{
Serial.begin(9600); // Debugging only
myservo.attach(10); // attaches the servo on pin 9 to the servo object

if (!driver.init())
Serial.println("init failed");
}

40
The setup() section just checks if we are receiving data from the RF receiver
properly or not.

void loop()
{
uint8_t buf[4];
uint8_t buflen = sizeof(buf);
int j=0;
int rtdata[10];
int data[2];
if (driver.recv(buf, &buflen)) // Non-blocking

We define an array buf to initially store the incoming data. The driver.recv()
takes care of that But this data will be of the uint8_t format and needs to be
converted into int before proceeding.

memcpy(rtdata,buf,sizeof(buf));
for(byte i=0;i<2;i++)
data[j++]=rtdata[i];

The above lines of code take care of that. First, we copy the data from buf to an
array called rtdata. Then, in the loop we move from one byte of rtdata to the
next and store those in data array. This is effective because instead of moving
from one data location to next, we shift byte by byte by declaring the variable i
of type byte in the loop initialiser. The j index takes care of the data array. Now
we have our angles in the array data.

if(data[0]>60){
spd=255;
analogWrite(motor,spd);
}
else if(data[0]<-60){
spd=0;
analogWrite(motor,spd); }

41
The element data[0] contains the angle related to the upward/downward
motion of the hand i.e. the roll. They will control the speed of the DC motors.
Both the DC motors are connected to pin defined by the variable motor(=5).

The function helps control the speed of the motors by employing the use of
PWM present on the Arduino board. This is the reason pin 5 was used here as it
is one of the PWM pins. As per our predefined values, if the angle is over 60°,
the vehicle reaches top speed instantly. This is done by spd variable attaining its
maximum value which is 255. Similarly is the angle is below -60°, the vehicle
instantly comes to halt, i.e. it works as a break system for instantly stopping the
vehicle.

Now, the two extreme scenarios out of the way, we need to define how the
vehicle accelerates and slows down.

else if(data[0]>7)
{ if(spd>250)
spd=255;
else
spd+=int(data[0]/5);
analogWrite(motor,spd);
}

else if(data[0]<-7)
{ if(spd<5)
spd=0;
else
spd+=int(data[0]/5);
analogWrite(motor,spd);
}

If the angle is in the range of 7° to 60°, the vehicle accelerates by the rate that
depends on the value of the angle divided by a scale factor which on limited
testing, 5 was found to be the best fit. The line spd+=int(data[0]/5) takes care of
that. The same is true if the angle is between 7° and 60° downwards, here the
only difference is that the vehicle decelerates at that rate.

42
It is the job of the coder to keep into account every scenario that might happen
in the real world. There may be a case where while increasing the speed
gradually, the speed exceeds its top limit which is 255. The first conditional
block if(spd>250) takes care of that. Same is taken care if the speed is trying to
go below 0 that is meaningless.

else{
spd=0;
analogWrite(motor,spd);
}

The idea of keeping the angle range from 7° to 60° was to make sure the vehicle
doesn not move with very small movements of the hand. That will lead to
instability. So, the vehicle should stay at rest if none of the aforementioned
conditions are met. The last else block takes care of that. It makes sure that the
hand needs to be continuously tilted in the upward/downward direction to
accelerate/decelerate the vehicle. After controlling the speed of the vehicle, it is
time to discuss the turning.

if(data[1]>30)
myservo.write(180); // tell servo to go to position
//in variable 'pos'
else if(data[1]<-30)
myservo.write(0);
else
myservo.write(90);
}

The pitch or the left/right motion of the hand is stored in the element data[1].
Here, a singular motion will define the turning. As per the construction, the
default position of the servomotor is 90°. If the pitch is over 30°, the motor
instantly shifts to 180° turning the front wheels in the right direction. Something
similar happens if the angle is over 30° in the other direction, the result here is
the motor moving to 0° turning the vehicle left. If the hand is inbetween the two
positons, the motor stays at its default position and vehicle goes on in a straight
line.

43
Robotic Arm

Transmitter section
The transmitter section of the robotic arm is pretty similar to the vehicle, the
only difference here being the existence of an extra value in the form of the data
from the flex sensor which controls the robotic gripper.

//Transmitter
#include<Wire.h>
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile

So, just like the transmitter section for the vehicle, the transmitter for the robotic
arm also makes use of the RadioHead (RH_ASK) library for the wireless
transmission of data and the Wire Library is used to obtain the data from the
MPU6050 Accelerometer-Gyroscope. The only difference here being that
instead of using just the MPU6050 sensor to convert physical actions into
electronic signals, a combination of actions defined by an MPU6050 sensor and
flex sensors are used. The MPU6050 sensor works in the same fashion as in the
case of the vehicle but here it is used to control the movement of the Robotic
arm at the joints. The defined values for the MPU6050 variables will make sure
how and when the arm mover left-right or up-down, which is essential when it
comes to picking up/dropping objects. The picking/dropping action is achieved
by the gripper at the end of the arm, whose movement is controlled by the Flex
sensor.

RH_ASK driver;
float roll,pitch;
const int MPU6050_addr=0x68;
int Data[3];
float AccX,AccY,AccZ,Temp,GyroX,GyroY,GyroZ;
int flex=0;
int flexPin = A0;

As the code reflects, in order to accommodate the data from the felex sensor, an
extra element is added to the data array and the analog pin (A0) to which the
flex sensor is connectd is defined.
44
void setup()
{ Wire.begin();
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}

void loop()
{

Wire.beginTransmission(MPU6050_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU6050_addr,14,true);
float Acc[] = {0,0,0};
Acc[0]=Wire.read()<<8|Wire.read();
Acc[1]=Wire.read()<<8|Wire.read();
Acc[2]=Wire.read()<<8|Wire.read();
Temp=Wire.read()<<8|Wire.read();
GyroX=Wire.read()<<8|Wire.read();
GyroY=Wire.read()<<8|Wire.read();
GyroZ=Wire.read()<<8|Wire.read();

Acc[0]/=16384; Acc[1]/=16384; Acc[2]/=16384;


roll = atan(Acc[1] / sqrt(pow(Acc[0], 2) + pow(Acc[2], 2))) * 180 / PI;
pitch = atan(-1 * Acc[0] / sqrt(pow(Acc[1], 2) + pow(Acc[2], 2))) * 180 / PI;
Serial.print("Roll="); Serial.print(roll);
Serial.print(" || Pitch="); Serial.println(pitch);

As expected, the code and its working till the extraction of data from the
MPU6050 sensor is exactly the same as shown above. The only difference will
come when we get the data from the flex sensor.

flex=analogRead(flexPin);

This single line of code performs that function. As described in the Working
section, the flex sensor simply works as a voltage divider. Ideally, it can have a

45
value of 0-5 V depending on how much it’s being bent. The function
analogRead() reads this value and convert this into a number ranging from 0 to
1023(10 bit).

Data[0]=int(round(roll));
Data[1]=int(round(pitch));
Data[2]=flex;
driver.send((uint8_t *)Data, 6);
driver.waitPacketSent();
delay(2500);
}

The rest of the code just involves writing the roll, pitch and flex data to first,
second and third element of the array data respectively and then transmitting the
data over the transmitter just like the vehicle. (Note the use of 6 instead of 4 in
the driver.send() function because there are 3 elements to transmit instead of 2).

Receiver section
:
Once the variables for the movements are transmitted, they are received and
converted into their corresponding angular values that are fed to the servo
motors at the joints and the gripper. The rotations of the servo motors facilitate
the arm and gripper movement and can be employed as an efficient object
picker/dropper and when combined with the vehicle, it adds a new dimension to
the applicability of the arm making sure that it is not fixed at a single location
and can be used for mobile applications as well.

//Receiver

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#include <Servo.h>

RH_ASK driver;
int Data[3];
Servo myservo1; // create servo objects to control a servo
Servo myservo2;
Servo myservo3;
Servo myservo4;
int pos1 = 0; // variables to store the servo position

46
int pos2 = 0;

The only difference from the vehicle here is the fact that we will be controlling
four servo motors with the data we receive which are described in the Working
section and in the figure below as well. We will call the four motors as 1,2,3
and 4. Servo 1 is the motor placed at the base that controls the left-right
movement of the arm. Servo 2 is the motor at the arm joint that controls up-
down movement. Servo 3 and 4 are the motors used for opening and closing the
gripper. To handle that four objects of the class Servo are declared.

void setup()
{
Serial.begin(9600); // Debugging only
myservo1.attach(5); // attaches the servo on pin 9 to the servo object
myservo2.attach(6);
myservo3.attach(9);
myservo4.attach(10);
if (!driver.init())
Serial.println("init failed");
}

The Servo motors are connected to four different PWM pins as described by the
attach() function in the setup().

void loop()
{
uint8_t buf[6];
uint8_t buflen = sizeof(buf);
int j=0;
int rtdata[10];
int data[3];
if (driver.recv(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump it.
//Serial.println("Message:\n");
//for(j=0;j<buflen;j++)
//Serial.println(buf[j]);
}
Serial.println("Data:");
memcpy(rtdata,buf,sizeof(buf));
for(byte i=0;i<3;i++)

47
data[j++]=rtdata[i];

The process followed till the extraction of data from the receiver and its
conversion into meaningful form is exactly the same as that in the case of the
vehicle, only difference being here we have an extra value coming from the flex
sensor. The change will come in how we use the values we are receiving to
define the position of the motors and the movement of the arm and gripper.

if(data[0]>60){
pos2=180;
myservo2.write(pos2);
}
else if(data[0]<-60){
pos2=0;
myservo2.write(pos2);
}

else if(data[0]>7)
{ if(pos2>170)
pos2=180;
else
pos2+=int(data[0]/5);
myservo2.write(pos2);
}

else if(data[0]<-7)
{ if(pos2<5)
pos2=0;
else
pos2+=int(data[0]/5);
myservo2.write(pos2);
}

else{

myservo2.write(pos2);
}

48
First let’s discuss the way in which the movement of motor 2 is defined. It is
pretty similar to how we handled the speed in case of the vehicle. We will use
the roll i.e. the upward/downward motion of the hand to control this motor. The
extreme positions of the motor are 180° (straight up) and 0° (straight down) and
this will happen only when the hand controlling the arm is 60° in the upward or
downward direction. Again, if the angle is between 7° and 60° in either
direction, the motor and thus the joint of the arm will move in that direction by
a factor of the angle divided by the scale factor defined by the line. Finally, if
the hand is not in upward/downward motion, the joint will stay at its last
recorded position.

All these movements of motor 2 will make sure the joint of the arm will move
up and down and can help picking up or dropping objects from the ground or at
a height.

if(data[1]>60){

pos1=180;
myservo1.write(pos1);
}
else if(data[1]<-60){
pos1=0;
myservo1.write(pos1);
}

else if(data[1]>7)
{ if(pos1>170)
pos1=180;
else
pos1+=int(data[1]/5);
myservo1.write(pos1);
}

else if(data[1]<-7)
{ if(pos1<5)
pos1=0;
else
pos1+=int(data[1]/5);
myservo1.write(pos1);
}

else{

49
myservo1.write(pos1);
}

Motor 2 only takes care of making sure that the arm reaches Infront of the
vehicle, but what if we want to pick up/drop the objects on the sides of the
vehicle. Motor 1 takes care of that. It’s movement is defined by the pitch or the
left/right tilt of the hand. It works in exactly the same way as Motor 2, just the
upward downward motion of the arm at joint 2 is replaced by right and left
movement of the arm at joint 1. Also, a motor that produces more torque and
can handle larger weights is used at joint 1 as it is the base of the entire arm.

if(data[2]>700)
{myservo3.write(180);
myservo4.write(0);
}
else
{myservo3.write(90);
myservo4.write(90);
}}

The motors 3 and 4 work together to open and close the gripper so that the arm
can pick up or drop the object. Its movement completely depends on the
bending of the flex sensor. As the flex sensor is bent more, its resistance and
hence voltage drop across it increases. We define if the value is over 3.42 V
(5*700/1023), the gripper should close. To close the gripper, the motors should
move in the opposite direction according to our construction. Thus, one of them
(motor 3) moves to 180° and the other (motor 4) in the opposite direction to 0°.
It should be noted that the default position of both the motors when the gripper
is open is 90° and it will stay so if the voltage across flex sensor is below 3.42V.

Combining all these snippets of code and uploading them to the Arduinos
handling receiver and transmitter portions for the vehicle and robotic arm, they
have the capacity to work in harmony as an efficient wireless, low-cost, mobile
pick-up and drop machine.

(Note: All the codes above can be found in their entirety in the Appendix section
of the report)

IMPLEMENTATION

50
In this section, we will discuss how the hardware and software part of the
project were brought together to work as a unit, the parts of the project we
actually implemented and tested experimentally, the parts we could not test and
the plan of action we wished to follow in order to achieve them.

As mentioned in the construction and working section along with pictures, the
vehicle was fully constructed and all its movements i.e. acceleration,
deceleration, left-right turning were tested experimentally with satisfactory
results.

Same goes for the robot arm as well, all joints were connected together and
placed on top of the vehicle. The complete movement of all the joints were
tested along with the opening and closing of the gripper. The gripper was found
to hold the objects as required.

The code was also uploaded to the Arduinos and they were interfaced with all
the other hardware: MPU6050 sensor, RF pair, Flex sensor, DC motors and
Servo motors. In the initial part of the project, all the hardware was tested to
make sure all the protocols were working fine. There was a problem regarding
the PWM pins for the DC motors and Servo motors trying to access the same
timer for their respective functions causing an error. This was corrected by
making changes in their respective header files making sure the timers do not
clash with each other. Also, the communication between the RF pair was tested
by sending raw data to make sure it was working perfectly.

Once this was achieved, in the next phase of code testing, data was taken from
the MPU6050 sensor and treated as input and this was used to move the motors
as required by our project. This was also individually tested for the vehicle by
speeding it up, slowing it down and making sure the axle turns left-right with
change in input.

Same was done for the robot arm, making sure all the joints respond and move
in harmony as per the input provided. The gripper was also tested and both
claws of the gripper were found to work in synchronization.

51
PROPOSED PLAN OF ACTION FOR PARTS
THAT WERE NOT TESTED

This previous section concludes all that was actually experimentally performed.
After this, we would have tried testing the motion of the vehicle and robot arm
as a complete unit, which was done on an individual level.

Also, the circuits of both transmitter sections were made on breadboards for
testing purposes and we would have transferred them to gloves as expected of
our project. We also could not test the RF transmission of both parts of the
project together, which we would have done next.

Apart from this, it was not tested how much weight the gripper could actually
hold and is there any limitation regarding the shapes and sizes of the objects it
can hold. The same would have been tested and required modification would
have been made to the gripper.

So, all the components of the were tested and verified on an individual level and
the next step in the plan of action would have been to test and verify them as a
complete unit and to make necessary modification so as to get an optimised
performance out of them.

52
CONCLUSIONS

The objective of this project has been tried to achieve, which was to develop
hardware and software for a gesture based robotic arm and vehicle that can be
controlled wirelessly.

From the limited observations and tests that were conducted, the vehicle and the
arm individually clearly show that the movement is accurate, easy to control
and user friendly. At the same time, there were some studies that could not be
performed that could have helped in better calibration of the arm and the vehicle
as a whole and could have led to modifications that would have improved the
system

Nevertheless, this robotic arm is expected to overcome problems such as


picking and placing objects in quick and easy manner in environments that are
hazardous or difficult to reach by humans, thus providing a mobile, wireless,
low-priced and robust pick and place alternative.

53
FUTURE SCOPE

The robot industry and studies regarding them have made giant leaps in the last
few decades and it would not be false to say that the future of this industry is
definitely automation but with correct amount of human oversight.

Although, the current project is a mobile, wireless, low-cost, robust way to


perform pick and pace operations and the list of applications is quite large,
modifications and updates can be made to the present design to get more out of
it in the future, widening the scope of application.

One feature that can be added to the current project with a few modifications is
to add a way to control the arm and vehicle not only through the hand
movements but also through a remote source, say a mobile application. Apart
from this, the range of operation can obviously be mad better by making use of
better sensors.

Next, we move on to the automation part, i.e. taking the whole project one step
forward, making sure the arm and vehicle moves on its own without any input.
This can be achieved by making use of an array of ultrasonic sensors on the
vehicle that can be employed to detect obstacles and chart the course of way
accordingly. The same can be used for the arm as well.

54
Apart from this, and the most exciting path this project can move on is to
incorporate machine learning along with the present code. Currently there are
some algorithms and studies have been going on for more optimised algorithms
that makes sure the arm detects the object to pick up on its own using sensors
that can be image based or ultrasonic. After this, the arm tries to find the best
way it should move depending on the restrains on its degrees of freedoms to
find the best way to pick up the object, this can be interfaced with Machine
learning to achieve the best results. Same can be done for the motion of the
vehicle.

Another field where this system can be employed is in the world of Prosthetics,
instead of taking input signal from a sensor such as an Gyroscope-
Accelerometer, if we can extract electrical signals directly from the nerves, it
can be used to drive the motion of the arm just like an ordinary human arm.
Research is ongoing in this field and if we can incorporate neural networks here
as well, it will make the working optimised and efficient.

Similarly, there are many ways this project can be improved and can be
modified and help in large scale applications in the future in different fields.

55
REFERENCES

 Accelerometer based gesture controlled robot using Arduino: Swarna


Prabha Jena, Sworaj Kumar Nayak, Saroj Kumar Sahoo, Sibu Ranjan
Sahoo, Saraswata Dash, Sunil Kumar Sahoo.
 Accelerometer Based Hand Gesture Controlled Robot: Pravin Vaishnav,
Shalini Tiwari.
 Hand Motion-Based Remote Control Interface with Vibrotactile
Feedback for Home Robots.
 Hand Gesture Based Wireless Controlled Robot: Dushyant Singh,
Riturvanjali Singh, Neelam Sharma,Sagar Shrivastav , and Ashutosh
Mittal.
 Tilt Sensing Using a Three-Axis Accelerometer: Mark Pedley.
 http://www.sensorwiki.org/doku.php/sensors/accelerome ter
 https://www.edn.com/electronics-blogs/eye-on-iot- /4437311/Using-433-
MHz-for-wireless-connectivity-inthe-Internet-of-Things
 https://www.arduino.cc/en/Main/ArduinoBoardLilyPad/
 https://www.instructables.com
 https://lastminuteengineers.com/433mhz-rf-wireless-arduino-tutorial/
 https://www.electronicshub.org/getting-started-arduino-mpu6050/
 http://www.circuitstoday.com/dc-motor-speed-control-arduino-pwm
 https://lastminuteengineers.com/433mhz-rf-wireless-arduino-tutorial
 https://en.wikibooks.org/wiki/Robotics/
 https://www.airspayce.com/mikem/arduino/RadioHead/
 https://www.vectorstock.com
 https://www.med-technews.com/

56
APPENDIX

Given below is the source code in its entirety for all the sections:

ROBOTIC VEHICLE

TRANSMITTER SECTION:

//Transmitter
#include<Wire.h>
#include <RH_ASK.h>
#include <SPI.h>

RH_ASK driver;
float roll,pitch;
const int MPU6050_addr=0x68;
int Angle[2];
float AccX,AccY,AccZ,Temp,GyroX,GyroY,GyroZ;

void setup()
{ Wire.begin();
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}

void loop()
{
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU6050_addr,14,true);
float Acc[] = {0,0,0};

57
Acc[0]=Wire.read()<<8|Wire.read();
Acc[1]=Wire.read()<<8|Wire.read();
Acc[2]=Wire.read()<<8|Wire.read();
Temp=Wire.read()<<8|Wire.read();
GyroX=Wire.read()<<8|Wire.read();
GyroY=Wire.read()<<8|Wire.read();
GyroZ=Wire.read()<<8|Wire.read();

Acc[0]/=16383; Acc[1]/=16383; Acc[2]/=16383;


roll = atan(Acc[1] / sqrt(pow(Acc[0], 2) + pow(Acc[2], 2))) * 180 / PI;
pitch = atan(-1 * Acc[0] / sqrt(pow(Acc[1], 2) + pow(Acc[2], 2))) * 180/PI;
Serial.print("Roll="); Serial.print(roll);
Serial.print(" || Pitch="); Serial.println(pitch);

Angle[0]=int(round(roll));
Angle[1]=int(round(pitch));

driver.send((uint8_t *)Angle, 4);


driver.waitPacketSent();
delay(500);
}

RECEIVER SECTION

//Receiver

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#include <Servo.h>

RH_ASK driver;
int motor=5;
int spd=0;
int Angle[2];
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position

58
void setup()
{
Serial.begin(9600); // Debugging only
myservo.attach(10); // attaches the servo on pin 9 to the servo object

if (!driver.init())
Serial.println("init failed");
}

void loop()
{
uint8_t buf[4];
uint8_t buflen = sizeof(buf);
int j=0;
int rtdata[10];
int data[2];
if (driver.recv(buf, &buflen)) // Non-blocking

memcpy(rtdata,buf,sizeof(buf));
for(byte i=0;i<2;i++)
data[j++]=rtdata[i];

if(data[0]>60){
spd=255;
analogWrite(motor,spd);
}
else if(data[0]<-60){
spd=0;
analogWrite(motor,spd); }
else if(data[0]>7)
{ if(spd>250)
spd=255;
else
spd+=int(data[0]/5);
analogWrite(motor,spd);
}

else if(data[0]<-7)
{ if(spd<5)
spd=0;
else
59
spd+=int(data[0]/5);
analogWrite(motor,spd);
}

else{
spd=0;
analogWrite(motor,spd);
}

if(data[1]>30)
myservo.write(180); // tell servo to go to position
//in variable 'pos'
else if(data[1]<-30)
myservo.write(0);
else
myservo.write(90);
}

ROBOTIC ARM

TRANSMITTER SECTION:

//Transmitter
#include<Wire.h>
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile

RH_ASK driver;
float roll,pitch;
const int MPU6050_addr=0x68;
int Data[3];
float AccX,AccY,AccZ,Temp,GyroX,GyroY,GyroZ;
int flex=0;
int flexPin = A0;

void setup()

60
{ Wire.begin();
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}

void loop()
{
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU6050_addr,14,true);
float Acc[] = {0,0,0};
Acc[0]=Wire.read()<<8|Wire.read();
Acc[1]=Wire.read()<<8|Wire.read();
Acc[2]=Wire.read()<<8|Wire.read();
Temp=Wire.read()<<8|Wire.read();
GyroX=Wire.read()<<8|Wire.read();
GyroY=Wire.read()<<8|Wire.read();
GyroZ=Wire.read()<<8|Wire.read();

Acc[0]/=16384; Acc[1]/=16384; Acc[2]/=16384;


roll = atan(Acc[1] / sqrt(pow(Acc[0], 2) + pow(Acc[2], 2))) * 180 / PI;
pitch = atan(-1 * Acc[0] / sqrt(pow(Acc[1], 2) + pow(Acc[2], 2))) * 180 / PI;
Serial.print("Roll="); Serial.print(roll);
Serial.print(" || Pitch="); Serial.println(pitch);

flex=analogRead(flexPin);

Data[0]=int(round(roll));
Data[1]=int(round(pitch));
Data[2]=flex;
driver.send((uint8_t *)Data, 6);
driver.waitPacketSent();
delay(2500);
}

61
RECEIVER SECTION:

//Receiver

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#include <Servo.h>

RH_ASK driver;
int Data[3];
Servo myservo1; // create servo objects to control a servo
Servo myservo2;
Servo myservo3;
Servo myservo4;
int pos1 = 0; // variables to store the servo position
int pos2 = 0;

void setup()
{
Serial.begin(9600); // Debugging only
myservo1.attach(5); // attaches the servo on pin 9 to the servo object
myservo2.attach(6);
myservo3.attach(9);
myservo4.attach(10);
if (!driver.init())
Serial.println("init failed");
}

void loop()
{
uint8_t buf[6];
uint8_t buflen = sizeof(buf);
int j=0;
int rtdata[10];
int data[3];
if (driver.recv(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump it.
//Serial.println("Message:\n");
//for(j=0;j<buflen;j++)

62
//Serial.println(buf[j]);
}
Serial.println("Data:");
memcpy(rtdata,buf,sizeof(buf));
for(byte i=0;i<3;i++)
data[j++]=rtdata[i];

if(data[0]>60){
pos2=180;
myservo2.write(pos2);
}
else if(data[0]<-60){
pos2=0;
myservo2.write(pos2);
}

else if(data[0]>7)
{ if(pos2>170)
pos2=180;
else
pos2+=int(data[0]/5);
myservo2.write(pos2);
}

else if(data[0]<-7)
{ if(pos2<5)
pos2=0;
else
pos2+=int(data[0]/5);
myservo2.write(pos2);
}

else{

myservo2.write(pos2);
}

if(data[1]>60){

pos1=180;
myservo1.write(pos1);
}

63
else if(data[1]<-60){
pos1=0;
myservo1.write(pos1);
}

else if(data[1]>7)
{ if(pos1>170)
pos1=180;
else
pos1+=int(data[1]/5);
myservo1.write(pos1);
}

else if(data[1]<-7)
{ if(pos1<5)
pos1=0;
else
pos1+=int(data[1]/5);
myservo1.write(pos1);
}

else{
myservo1.write(pos1);
}

if(data[2]>700)
{myservo3.write(180);
myservo4.write(0);
}
else
{
myservo3.write(90);
myservo4.write(90);
}
}

64
65

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy