Arduino Tutorials

Arduino with Accelerometer Tutorial | Arduino ADXL335

Hello there, Do you want to know how an ADXL335 or GY61 accelerometer works? Are you working on a DIY project that calls for the use of an accelerometer but you’re not sure how? If so, you’ve come to the right place. In this article, we’ll go over how to function, use, and interface an Arduino with accelerometer in a step-by-step guide. Hence, I hope you find this useful. We at Techatronic have already uploaded several Arduino Tutorials and detailed project guides related to Arduino which will be useful to learn the basics and programming of Arduino.

Arduino with Accelerometer

What Is Accelerometer?

Many Arduino projects, as well as other small electronics, use accelerometers as a sensor module, which outputs the changes in acceleration caused due to different factors. It has a three-axis sensor, which helps it can read changes in three dimensions, namely X, Y, and Z, Along with this there are many other sensors available. Arduino with accelerometer gives us the option to monitor all the 3 axis data on the serial monitor. According to the need, this can be adjusted. These three value helps to make many of electronics project and products. self-balancing robots are in trending nowadays.

HTML Image as link
Qries

The Accelerometer module consists of ADXL335 ic along with a 3.3v voltage regulator and some capacitors and resistors, so it helps the module measure the acceleration in the range of ±3g and output proportional analog values of range 0 t0 1023. based on these changes we have made Gesture Control Car,

Accelerometer

How Does it Work?

The ADXL335 is MEMS (Micro Electro Mechanical Systems) device that operates on the concept of variable capacitance between two fixed plates. 
This can be used to determine the tilt, shock vibration, in addition to the direction of the object. 
 
There are various uses of Accelerometers such as in Drones (to maintain stability in the air), smartphones (to adjust the orientation of the screen from portrait to landscape and vice-versa when rotated),  Game controllers and pads, Joysticks (to track the movement and direction), and also in Disc Drives( to prevent data loss when free fall is detected), Sports devices and trackers and much more.
 

In fact with the use of  ADXl335 accelerometer sensor Arduino and some more sensor modules in addition to these, we can also make many DIY projects such as Quadcopters and Hexacopters, RC planes, etc.

Components Required:-

  • Arduino Uno
  • Adxl335 Accelerometer Module
  • LEDs(Red, Green, Blue, and Yellow)
  • 220-ohm Resistor
  • Breadboard
  • Jumper Wires
  • USB cable to connect Arduino Uno with Computer
Arduino with Accelerometer component

Arduino ADXL335 Circuit Diagram

Arduino ADXL335 Circuit Diagram

Arduino UNO3 Axis Accelerometer
A1 PinY
A0 PinX
( +5V ) VCC
GND GND
Arduino LED BLED GLED RLED Y220 Ohm Resistor
D7 PinAnode Pin    
D6 Pin Anode Pin   
D5 Pin  Anode Pin  
D5 Pin   Anode Pin 
GND    Terminal 1
 Cathode PinCathode PinCathode PinCathode PinTerminal 2
  • VCC of Module to 5V pin of Arduino UNO.
  • GND of Module to GND pin of Arduino UNO.
  • X* of Module to A0 of Arduino UNO.
  • Y* of Module to A1 of Arduino UNO.
  • Positive’+’ ends of LEDs to pins 4,5,6,7 of Arduino UNO Respectively.
  • Negative ‘-‘ ends of LEDs to GND pin of Arduino UNO using 220-ohm Resistor.

 ADXL335 Arduino code

 //TECHATRONIC.COM   
 int m=0, n=0;  
 void setup()  
 {  
   pinMode(A0, INPUT);  
   pinMode(A1, INPUT);  
   pinMode(4,OUTPUT);  
   pinMode(5,OUTPUT);  
   pinMode(6,OUTPUT);  
   pinMode(7,OUTPUT);  
   Serial.begin(9600);  
 }  
 void loop()   
 {  
   m = analogRead(A0);  
   n = analogRead(A1);  
   Serial.println(m);  
   delay(100);  
   Serial.println(n);  
   delay(100);  
  if(n>=375)  
   {  
     digitalWrite(4,HIGH);  
     Serial.println("F");  
   }  
   else if(n<=320)  
   {   
     digitalWrite(5,HIGH);  
     Serial.println("B");  
   }   
  else if(m>=375)  
   {  
     digitalWrite(6,HIGH);  
     Serial.println("R");  
   }  
  else if(m<=315)  
   {  
    digitalWrite(7,HIGH);  
    Serial.println("L");  
   }  
   else  
   {  
    digitalWrite(4, LOW);  
    digitalWrite(5, LOW);  
    digitalWrite(6, LOW);  
    digitalWrite(7, LOW);  
    Serial.println("N");  
   }  
   }  
Arduino with Accelerometer

After Uploading the code, the output can be seen by opening the serial monitor in your Arduino IDE. If you need any help, you can ask them in the comment section below. I hope you liked this article.

HTML Image as link
Qries

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button