Send Mobile Accelerometer Data to Android using Bluetooth

Arduino Acelerometer Bluetooth let you use mobile acelerometer in the arduino . It is really easy to implement .Using accelerometer module with arduino is either difficult or it contains alot of garbage values which require callibration . In case of accelerometer callibration is headach .Then why not use mobile’s accelrometer app for arduino .It does not require callibration.

Accelerometer is being used in various projects it tells us the position of the device . Like in case of drone acelerometer will tell us whether it is heading upward , downward , backward , forward or side ways . With the help of accelrometer data we can also determine the linear accelaration of the device .

Get the App : https://play.google.com/store/apps/details?id=plutoapps.accerelometerbluetooth

Example Project : 
Code :

int x=0;
char xx='0';
int mydata=0;
int Led_positive_xx,Led_negative_x,Led_positive_xy,Led_negative_y,Led_positive_xz,Led_negative_z;
                          
String datax,datay,dataz;
void setup() {            // connect Leds at pin numbers 13,12,11,10,8,7
Led_positive_xx=13;      // initalizing leds 
Led_negative_x=12;
Led_positive_xy=11;
Led_negative_y=10;
Led_positive_xz=8;
Led_negative_z=7;
// put your setup code here, to run once:
Serial.begin(9600);     // establish connection

pinMode(Led_positive_xx,OUTPUT);   
pinMode(Led_negative_x,OUTPUT);
pinMode(Led_positive_xy,OUTPUT);
pinMode(Led_negative_y,OUTPUT);
pinMode(Led_positive_xz,OUTPUT);
pinMode(Led_negative_z,OUTPUT);
datax="";
datay="";
dataz="";
xx='0';

}

void loop() {

// put your main code here, to run repeatedly:
if(Serial.available()){
x=Serial.read();
if(x!='\n' && xx=='0'){
datax+=(char)x;
}
else if (x=='\n' && xx=='0'){
mydata=datax.toInt();
if(mydata > 3){          
digitalWrite(Led_positive_xx,HIGH);
}else if(mydata < -1 ){
digitalWrite(Led_negative_x,HIGH);
}else {
digitalWrite(Led_positive_xx,LOW);
digitalWrite(Led_negative_x,LOW);
}

datax="";
xx='1';
}
else if (xx=='1' && x!='a'){
datay+=(char)x;

}
else if (x=='a' && xx=='1'){
mydata=datay.toInt();
if(mydata > 3){
digitalWrite(Led_positive_xy,HIGH);
}else if(mydata < -1 ){
digitalWrite(Led_negative_y,HIGH);
}else {
digitalWrite(Led_positive_xy,LOW);
digitalWrite(Led_negative_y,LOW);
}

datay="";
xx='2';
}
else if (x!='b' && xx=='2'){
dataz+=(char)x;
}
else if (x=='b' && xx=='2'){
mydata=dataz.toInt();
if(mydata > 3){
digitalWrite(Led_positive_xz,HIGH);
}else if(mydata < -1 ){
digitalWrite(Led_negative_z,HIGH);
}else {
digitalWrite(Led_positive_xz,LOW);
digitalWrite(Led_negative_z,LOW);
}
dataz="";
xx='0';
}
}

}

You May Also Like

About the Author: quzal

Leave a Reply

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