Monday 22 January 2018

ADXL335 Gesture Control Robot using Arduino

Adxl335 is a small, thin, low power, complete 3-axis accelerometer with signal conditioned voltage outputs. The product measures acceleration with a minimum full-scale range of ±3 g. It can measure the static acceleration of gravity in tilt sensing applications, as well as dynamic acceleration resulting from motion, shock, or vibration.

How does accelerometer works?

The capacitance accelerometer senses changes in capacitance between microstructures located next to the device. If an accelerative force moves one of these structures, the capacitance will change and the accelerometer will translate that capacitance to voltage for interpretation.

About this project:

In this project we interface adxl335 with Arduino to move vehicle (forward / backward / left / right).
Change in sensor values whenever it is tilted in the (X-direction) vehicle has to move forward and when it is tilted in inverse of that direction vehicle runs backward. Similarly if sensor is tilted in (Y-direction) vehicle turns either left or right simultaneously inverse to each other so that it can turn easily.
When sensor is in flat position rover has to stop.
By tilting adxl335 you can calibrate and change value for X and Y coordinates it will be shown in serial monitor in Arduino IDE

Components Required:

Arduino Uno 
ADXL335 
L298N Motor Driver  or L293D Motor Driver 
4 Wheel Chassis Kit 
12V Battery 
Alligator Clips
9V Battery 
9V Battery Snap 
DC Jack
Jumper Wires M to F 
Jumper Wires F to F 

Circuit Diagram:

Here connect 12V battery to L298N motor driver directly and connect Arduino Uno using DC jack.
which is not shown in this diagram

Arduino Code:

In this code Z-axis values written but it is not required.
Here ADXL335 directly connected to Arduino Uno. Since VCC and GND pin which is placed in analog slot so i assigned digital pin 19 high for VCC which is in A5 and digital pin 18 low for GND which is in A4.
int xPin = A3; //X axis input
int yPin = A2; //Y axis input
int zPin = A1; //Z axis input

int D1=10, D2=11, D3=12, D4=13;  //Output pins connected to 10,11,12,13
long x;  //Variable for storing X Coordinates
long y;  //Variable for storing Y Coordinates
long z;  //Variable for storing Z Coordinates

void setup()
{
  Serial.begin(9600);
  pinMode(19, OUTPUT);
  pinMode(18, OUTPUT);
  digitalWrite(19, HIGH);
  digitalWrite(18,LOW);
  pinMode(D1, OUTPUT);
  pinMode(D2, OUTPUT);
  pinMode(D3, OUTPUT);
  pinMode(D4, OUTPUT);
}
void loop()
{
  x = analogRead(xPin);  //Reads X coordinates
  y = analogRead(yPin);  //Reads Y coordinates
  z = analogRead(zPin);  //Reads Z coordinates
  Serial.print("x= ");
  Serial.print(x);
  Serial.print(" y= ");
  Serial.print(y);
  Serial.print(" z= ");
  Serial.print(z);
  delay(500);

if(x<300)  //Change the value for adjusting sensitivity
forward();
else if(x>350)  //Change the value for adjusting sensitivity
backward();
else if(y<300)  //Change the value for adjusting sensitivity
left();
else if(y>350)  //Change the value for adjusting sensitivity
right();
else
stop_();
}
void stop_()
{
  Serial.println("");
  Serial.println("STOP");
  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(D4, LOW);
}
void forward()
{
  Serial.println("");
  Serial.println("Forward");
  digitalWrite(D1, HIGH);
  digitalWrite(D2, LOW);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, LOW);
}
void backward()
{
  Serial.println("");
  Serial.println("Backward");
  digitalWrite(D1, LOW);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, LOW);
  digitalWrite(D4, HIGH);
}
void left()
{
  Serial.println("");
  Serial.println("Left");
  digitalWrite(D1, HIGH);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(D4, HIGH);
}
void right()
{
  Serial.println("");
  Serial.println("Right");
  digitalWrite(D1, LOW);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, LOW);
}

No comments:

Post a Comment

SMART BLIND STICK The smart blind stick is the project made to help the blind people who is suffering when walking.It just uses to de...