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:
Wed Sep 26 12:15:00 2012 +0000
Revision:
0:0c4fafa398b4
Child:
1:5a64632b1eb9
Sensor Test; Acc, Gyro working, result on LCD (servo lib included)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 0:0c4fafa398b4 1 #include "mbed.h"
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 0:0c4fafa398b4 6
maetugr 0:0c4fafa398b4 7 PinName kl[4] = {LED1, LED2, LED3, LED4};
maetugr 0:0c4fafa398b4 8 LED Led();
maetugr 0:0c4fafa398b4 9 TextLCD LCD(p5, p6, p7, p8, p9, p10, p11, TextLCD::LCD16x2); // RS, RW, E, D0, D1, D2, D3, Typ
maetugr 0:0c4fafa398b4 10
maetugr 0:0c4fafa398b4 11 // Sensor initialisation
maetugr 0:0c4fafa398b4 12 Gyro Gyro(p28, p27);
maetugr 0:0c4fafa398b4 13 ADXL345 Acc(p28, p27);
maetugr 0:0c4fafa398b4 14
maetugr 0:0c4fafa398b4 15 int main() {
maetugr 0:0c4fafa398b4 16
maetugr 0:0c4fafa398b4 17 LCD.printf("FlyBed v0.1");
maetugr 0:0c4fafa398b4 18
maetugr 0:0c4fafa398b4 19 wait(2);
maetugr 0:0c4fafa398b4 20 int j = -1;
maetugr 0:0c4fafa398b4 21 int Gyro_data[3];
maetugr 0:0c4fafa398b4 22 int Acc_data[3];
maetugr 0:0c4fafa398b4 23
maetugr 0:0c4fafa398b4 24 Acc.setPowerControl(0x00);
maetugr 0:0c4fafa398b4 25 Acc.setDataFormatControl(0x0B);
maetugr 0:0c4fafa398b4 26 Acc.setDataRate(ADXL345_3200HZ);
maetugr 0:0c4fafa398b4 27 Acc.setPowerControl(MeasurementMode);
maetugr 0:0c4fafa398b4 28
maetugr 0:0c4fafa398b4 29 while(1) {
maetugr 0:0c4fafa398b4 30
maetugr 0:0c4fafa398b4 31 Gyro.read(Gyro_data);
maetugr 0:0c4fafa398b4 32 Acc.getOutput(Acc_data);
maetugr 0:0c4fafa398b4 33
maetugr 0:0c4fafa398b4 34 //LCD.cls(); // Display löschen
maetugr 0:0c4fafa398b4 35 LCD.locate(0,0);
maetugr 0:0c4fafa398b4 36 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 37 LCD.locate(1,0);
maetugr 0:0c4fafa398b4 38 //LCD.printf("%d|%d|%d %d", gmitt[0]/j,gmitt[1]/j,gmitt[2]/j,gyro.readTemp()); //roll pitch yaw
maetugr 0:0c4fafa398b4 39 LCD.locate(1,0);
maetugr 0:0c4fafa398b4 40 LCD.printf("%d %d %d ", (int16_t)Acc_data[0],(int16_t)Acc_data[1],(int16_t)Acc_data[2]);
maetugr 0:0c4fafa398b4 41
maetugr 0:0c4fafa398b4 42 j++;
maetugr 0:0c4fafa398b4 43
maetugr 0:0c4fafa398b4 44 //Led[j%4] = !Led[j%4];
maetugr 0:0c4fafa398b4 45
maetugr 0:0c4fafa398b4 46 wait(0.1);
maetugr 0:0c4fafa398b4 47
maetugr 0:0c4fafa398b4 48 }
maetugr 0:0c4fafa398b4 49 }