Yarra
February 15, 2016, 10:10am
1
For a college project im trying to turn a common motion sensor code into a gesture device using code I found a while ago.
I really don't have a lot of backgroud knowledge dealing with arduino and am now struggling with tons of errors thrown at me when i try to upload the code to the board.
Can someone tell me what I'm missing?
stolen_bag.ino (1.65 KB)
Please help us by posting the code and the full error messages here. When you do please use code tags to format the code and messages.
system
February 15, 2016, 12:19pm
3
// MPU-6050 test for movement
//
// mostly taken from:
// MPU-6050 Short Example Sketch
// By Arduino User JohnChi
// August 17, 2014
// Public Domain
//circuit:
// Arduino Ground –> MPU VCC
// Arduino 5V –> MPU VCC
// Arduino A4 (SDA) –> MPU SDA
// Arduino A5(SCL) –> MPU SCL
#include<Wire.h>
const int MPU=0x68; // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
int OldAcX,OldAcY,OldAcZ,OldTmp,OldGyX,OldGyY,OldGyZ;
int AcSensitivity = 500;
boolean moved = false;
void setup(){
Wire.begin();
Wire.beginTransmission(MPU);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
Serial.begin(9600);
}
void loop(){
Wire.beginTransmission(MPU);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU,14,true); // request a total of 14 registers
AcX=Wire.read()<<8|Wire.read 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L);
AcY=Wire.read()<<8|Wire.read 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L);
AcZ=Wire.read()<<8|Wire.read 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L);
Tmp=Wire.read()<<8|Wire.read 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L);
GyX=Wire.read()<<8|Wire.read 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L);
GyY=Wire.read()<<8|Wire.read 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L);
GyZ=Wire.read<<8|Wire.read 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L);
}
if (abs(OldAcX - AcX) > AcSensitivity) {
moved = true;
}
if (abs(OldAcY - AcY) > AcSensitivity) {
moved = true;
}
if(abs (OldAcY - AcY) > AcSensitivity) {
moved = true;
}
if (moved == true) {
Serial.println("MOVED");
}
OldAcX = AcX;
OldAcY = AcY;
OldAcZ = AcZ;
moved = false;
delay(333);
}