NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.

Dependencies:   mbed MODI2C

Committer:
maetugr
Date:
Fri Sep 28 13:24:03 2012 +0000
Revision:
1:5a64632b1eb9
Parent:
0:0c4fafa398b4
Child:
2:93f703d2c4d7
bevor anpassung/vorschl?ge f?r ADXL345 library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 1:5a64632b1eb9 1 #include "mbed.h" // Standar Library
maetugr 0:0c4fafa398b4 2 #include "LCD.h" // Display
maetugr 0:0c4fafa398b4 3 #include "LED.h" // LEDs
maetugr 0:0c4fafa398b4 4 #include "L3G4200D.h" // Gyro
maetugr 0:0c4fafa398b4 5 #include "ADXL345.h" // Acc
maetugr 1:5a64632b1eb9 6 #include "Servo.h" // Motor
maetugr 0:0c4fafa398b4 7
maetugr 1:5a64632b1eb9 8 // initialisation
maetugr 1:5a64632b1eb9 9 LED LEDs;
maetugr 0:0c4fafa398b4 10 TextLCD LCD(p5, p6, p7, p8, p9, p10, p11, TextLCD::LCD16x2); // RS, RW, E, D0, D1, D2, D3, Typ
maetugr 1:5a64632b1eb9 11 L3G4200D Gyro(p28, p27);
maetugr 0:0c4fafa398b4 12 ADXL345 Acc(p28, p27);
maetugr 1:5a64632b1eb9 13 Servo Motor(p12);
maetugr 0:0c4fafa398b4 14
maetugr 0:0c4fafa398b4 15 int main() {
maetugr 1:5a64632b1eb9 16 // LCD/LED init
maetugr 1:5a64632b1eb9 17 LCD.cls(); // Display löschen
maetugr 0:0c4fafa398b4 18 LCD.printf("FlyBed v0.1");
maetugr 1:5a64632b1eb9 19 LEDs.roll(2);
maetugr 1:5a64632b1eb9 20 //LEDs = 15;
maetugr 0:0c4fafa398b4 21
maetugr 0:0c4fafa398b4 22 int Gyro_data[3];
maetugr 0:0c4fafa398b4 23 int Acc_data[3];
maetugr 0:0c4fafa398b4 24
maetugr 0:0c4fafa398b4 25 while(1) {
maetugr 0:0c4fafa398b4 26
maetugr 0:0c4fafa398b4 27 Gyro.read(Gyro_data);
maetugr 0:0c4fafa398b4 28 Acc.getOutput(Acc_data);
maetugr 0:0c4fafa398b4 29
maetugr 0:0c4fafa398b4 30 LCD.locate(0,0);
maetugr 0:0c4fafa398b4 31 LCD.printf("%d %d %d |%d ", Gyro_data[0],Gyro_data[1],Gyro_data[2],Gyro.readTemp()); //roll(x) pitch(y) yaw(z)
maetugr 0:0c4fafa398b4 32 LCD.locate(1,0);
maetugr 1:5a64632b1eb9 33 LCD.printf("%d %d %d %d ", (int16_t)Acc_data[0],(int16_t)Acc_data[1],(int16_t)Acc_data[2], 1000 + abs((int16_t)Acc_data[1]));
maetugr 0:0c4fafa398b4 34
maetugr 1:5a64632b1eb9 35 if(abs((int16_t)Acc_data[0]) > 200)
maetugr 1:5a64632b1eb9 36 Motor.initialize();
maetugr 0:0c4fafa398b4 37
maetugr 1:5a64632b1eb9 38 Motor = 1000 + abs((int16_t)Acc_data[1]); // Motorwert anpassen
maetugr 0:0c4fafa398b4 39
maetugr 1:5a64632b1eb9 40 LEDs.rollnext();
maetugr 0:0c4fafa398b4 41 wait(0.1);
maetugr 0:0c4fafa398b4 42
maetugr 0:0c4fafa398b4 43 }
maetugr 0:0c4fafa398b4 44 }