Monday, 22 January 2018

Arduino Basics: Playing around with ADXL335

What is ADXL335?
The 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 an accelerometer work?
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.
So, what does this circuit which we are going to design do?
So, we will interface the ADXL335 accelerometer with Arduino and also understand with the help of LED’s the change in sensor values every time the sensor is tilted/vibrated. Whenever we tilt the sensor in the x-direction, the red LED will glow, Similarly orange for Y-direction and yellow for z-direction.
Components required:
ADXL335
Three LED’s of different colours
Three 220 ohm Resistors
Arduino Uno 
Breadboard
Jumper wires
Circuit diagram
Here is your breadboard layout, Connect as below and upload the given tested code and you are ready with your ADXL335!
const int ledx= 13;
const int ledy=12;
const int ledz= 8;      
const int xpin = A0;                  // x-axis of the accelerometer
const int ypin = A1;                  // y-axis
const int zpin = A2;                  // z-axis (only on 3-axis models)

void setup()
{
  // initialize the serial communications:
  Serial.begin(9600);

  
  pinMode(ledx, OUTPUT);
  pinMode(ledy, OUTPUT);
  pinMode(ledz, OUTPUT);
}

void loop()
{
  // print the sensor values:
  Serial.print(analogRead(xpin));
  // print a tab between values:
  Serial.print("t");
  Serial.print(analogRead(ypin));
  // print a tab between values:
  Serial.print("t");
  Serial.print(analogRead(zpin));
  Serial.println();
  // delay before next reading:
  delay(100);
  if((analogRead(xpin)<300))
  {
    digitalWrite(ledx, HIGH);
  }
  else
  {
    digitalWrite(ledx, LOW);
  }
 if((analogRead(ypin)<300))
  {
    digitalWrite(ledy, HIGH);
  }
  else
  {
    digitalWrite(ledy, LOW);
  }
   if((analogRead(zpin)<300))
  {
    digitalWrite(ledz, HIGH);
  }
  else
  {
    digitalWrite(ledz, 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...