How to use ADXL335 to realize the design of gesture control robot
Source: InternetPublisher:containsmachine Keywords: Robot wireless control ADXL335 Updated: 2023/12/25
This wirelessly controlled robot car uses gestures: the tilt/direction of the hand to drive forward, backward, left or right.
Talking about robots, gesture controlled robots are one of the most common project types for hobbyists and students to understand and implement microcontroller knowledge in physics and real-life projects. The concept behind it is simple: the direction of the palm controls the movement of the robot car. But if you want to ask how is it done? Then let us break it down carefully.
To understand better, we will go through understanding the role and functionality of each component and then combining them to achieve the desired performance.
1. ADXL335 (accelerometer)
The accelerometer's function is simple: sense the direction of your wrist. Accelerometers measure acceleration, including the acceleration due to gravity "g". Therefore, we can use the accelerometer to sense the orientation of the wrist by measuring the "g" component on any particular axis of the ADXL335 as shown in the image below:
Due to the tilt of the hand, the angle of the X and/or Y axes changes with the vertical direction, so a component of the "g" acceleration also acts on them, which can be measured and therefore indicates the direction of the hand.
The ADXL335 can measure acceleration up to 3g and interfaces with the Arduino by connecting its axis pin to the Arduino's analog pin. The accelerometer outputs a voltage value proportional to acceleration.
In this project, the accelerometer is connected to an Arduino Nano and attached to the palm of the hand. The ADXL335 output voltage ranges from 0 to Vcc (applied voltage is typically 3.3V) and is read by the Arduino's analog pins. So to the user we get a value ranging from 0 to 1024 (10-bit ADC). Different orientations produce different simulated values for each axis, which are then mapped to different robot motions.
The circuit diagram of the accelerometer is:
The test code to understand the working of ADXL335 is as follows:
You can run this program to see the values for tilting your palms and wrists forward, backward, left, and right, which values will ultimately be used to control the robot.
2. RF-433 Transmitter and Receiver
The function of the RF module is simple: transmit command data from the wrist Arduino Nano to the motors that control the Arduino Uno. The RF module uses radio waves at 433hz frequency, hence the name RF-433. They use amplitude modulation to send data, but without going into too many technical details and keeping it simple, they will be used to transmit commands to the robot, namely: move forward, backward, right or left. In the absence of data, there is stillness. Their operating range is up to 10 meters.
Now to understand how to implement the RF module in our project, let us deal with the transmitter and receiver circuits sequentially.
transmitter circuit
The transmitter circuit consists of two parts: transmitter RF and encoder HT12E. The transmitter consists of a data pin, an antenna, a ground and power supply. It is the job of the HT12E encoder to provide data to the transmitter. The encoder consists of 4 data pins that can send data. We will use these 4 data pins to represent the four motions, a high level on these pins will each represent one of the four motions, and a low level on all pins will represent rest.
The circuit diagram is shown in the figure:
The left pins (A0-A7) are the address pins and define the pair that will exchange data (a transmitter and receiver with the same address will only share data). We set A0-A7 to LOW (ground).
The data input pins are connected to the Arduino digital pins (6 to 9 in this project) and they will output the command data as:
Digital pin commands (when high)
9 forwards
10 reverse
11 left
12 right
We will write the digital pin high based on the input of the ADXL335 to perform the desired movement.
receiving circuit
The receiver circuit is exactly similar to the transmitter circuit shown, but instead of the data pins being outputs to the Arduino, in this case they will be read as inputs to receive commands from the Arduino Uno and run the motors as needed:
To simplify, instead of the complex circuit as shown, you can put the LED in series with a 1K resistor at pin 17 to indicate the correct connection to the transmitter.
3. Motor shield
The motor shield is the easiest part to handle due to the availability of Adafruit library AFMotor, link:- https://github.com/adafruit/Adafruit-Motor-Shield-library
Download and copy the library in the Arduino libraries folder so you can include it in your program sketch.
An example of the AFMotor library is shown below:
#include
4. Combine all the parts
The last and final part consists of putting all the above parts together to form a complete robot that follows the commands of the hand!
Since the motor shield uses almost all digital pins, we will use the analog pins of the Arduino Uno to read the receiver data. The final circuit diagram looks like this:
The motor shield handles the connection to the motor. Connect the 9V battery to the shielded power input.
NOTE: I personally prefer to connect a 2 or even 3.9V battery in parallel to the shield power input to provide enough power to run all four motors. I have connected the four motors in a group of 2 (the same side motors are connected together in parallel so only motor points 3 and 4 are needed to run).
Final code
Arduino Nano:
int x_axis = 0;
int y_axis = 0;
int forward = 9;
int backward = 10;
int right = 11;
int left = 12;
void setup()
{
pinMode(A0, INPUT); //X-Axis
pinMode(A3 , OUTPUT); //Y-Axis
pinMode(forward, OUTPUT); //HIGH to move Forward
pinMode(backward, OUTPUT); //HIGH to move Backward
pinMode(right, OUTPUT); //HIGH to move Right
pinMode( left, OUTPUT); //HIGH to move Left
Serial.begin(9600);
}
void loop()
{
x_axis = analogRead(A0);
y_axis = analogRead(A3);
Serial.print(" X = ");
Serial. println(x_axis);
Serial.print(" Y = ");
Serial.println(y_axis);
if (y_axis >= 390)
{
Serial.println("Forward");
digitalWrite(forward, HIGH);
}
else
{
if (y_axis <= 310)
{
Serial.println("BACK");
digitalWrite(backward, HIGH);
}
else
{
if (x_axis >= 380)
{
Serial.println("RIGHT");
digitalWrite(right, HIGH);
}
else
{
if (x_axis <= 320)
{
Serial.println("LEFT");
digitalWrite(left, HIGH);
}
Serial.println(" ");
}
}
}
delay(200);
if (x_axis > 320 && x_axis < 380 && y_axis > 310 && y_axis < 390)
{
digitalWrite(forward, LOW);
digitalWrite(backward, LOW);
digitalWrite(right, LOW);
digitalWrite(left, LOW);
}
}
#include
Transmitter circuit:
Accelerometer:
Complete all modules:
- Improved circuit diagram of 8050 transistor emitter drive relay
- SN75370 Dual MOS Memory Interface Circuit
- Interface circuit composed of 74LS164 and 8051 microcontroller
- AD8351 and SAW filter interface circuit
- How to use ADXL335 to realize the design of gesture control robot
- 815e motherboard
- 24cxx replicator circuit
- Production of infrared receiving controller based on AT89C2051
- ISP2 using real USB chip and M8
- Decoding infrared remote control using microcontroller
- Robot sound generator
- Real-time speech recognition system application circuit diagram in home monitoring robot
- Speech recognition system circuit design for home monitoring robot application
- Gyro amplifier circuit
- Robot wireless remote control receiving circuit
- Robot wireless remote control transmitter circuit
- Robot circuit that can determine obstacles
- SNS9201 (household appliances, robots, medical equipment or alarm devices) infrared sensing signal processing circuit
- SNS9201 (household appliances, robots, medical equipment or alarm devices) infrared sensing signal processing circuit
- Light chasing robot