Skip to content

Instantly share code, notes, and snippets.

@emretezcan
Created October 2, 2018 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emretezcan/8c699b570d7b104f6d26345b484196f6 to your computer and use it in GitHub Desktop.
Save emretezcan/8c699b570d7b104f6d26345b484196f6 to your computer and use it in GitHub Desktop.
#include <SPI.h>
#include <MPU6050.h>
#include <Servo.h>
MPU6050 ACC_GYR;
int16_t accx, accy, accz;
int16_t gyrx, gyry, gyrz;
int deger ,deger2,ss1,ss2,a;
Servo s1,s2;
void setup() {
ACC_GYR.initialize();
Serial.begin(9600);
s1.attach(3);
s2.attach(4);
}
void loop() {
s1.write(ss1+10);
s2.write(ss2-10);
ACC_GYR.getMotion6(&accx, &accy, &accz, &gyrx, &gyry ,&gyrz);
deger=map(accx,-17000,17000,0,150);
deger2=map(accy,-17000,17000,0,150);
if(ss1-deger<-2){
ss1=ss1+1;
}
if(ss1-deger>2){
ss1=ss1-1;
}
if(ss2-deger2<-2){
ss2=ss2+1;
}
if(ss2-deger2>2){
ss2=ss2-1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment