Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Quadrocopter by
main.cpp@9:9185d37e061f, 2017-08-08 (annotated)
- Committer:
- MarcoF89
- Date:
- Tue Aug 08 08:32:25 2017 +0000
- Revision:
- 9:9185d37e061f
- Parent:
- 8:769ff3814355
- Child:
- 10:16ca5e9ee0dc
Steckerbelegung zum Q-Brain
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MarcoF89 | 6:27a09e8bebfb | 1 | #include "mbed.h" |
MarcoF89 | 6:27a09e8bebfb | 2 | #include "stdio.h" |
MarcoF89 | 6:27a09e8bebfb | 3 | #include <Timer.h> |
MarcoF89 | 6:27a09e8bebfb | 4 | #include "messen.h" |
MarcoF89 | 7:a54c97795013 | 5 | |
MarcoF89 | 6:27a09e8bebfb | 6 | static Serial pc(SERIAL_TX, SERIAL_RX); |
MarcoF89 | 6:27a09e8bebfb | 7 | static SPI spi(PE_6,PE_5,PE_2); //mosi,miso,sclk |
MarcoF89 | 6:27a09e8bebfb | 8 | static DigitalOut ncs(PE_4); //ssel |
MarcoF89 | 6:27a09e8bebfb | 9 | |
MarcoF89 | 7:a54c97795013 | 10 | static AnalogIn potis_1 (PF_3); |
MarcoF89 | 7:a54c97795013 | 11 | static AnalogIn potis_2 (PF_10); |
MarcoF89 | 7:a54c97795013 | 12 | static AnalogIn potis_3 (PF_4); |
MarcoF89 | 7:a54c97795013 | 13 | static AnalogIn potis_4 (PF_5); |
MarcoF89 | 7:a54c97795013 | 14 | |
MarcoF89 | 7:a54c97795013 | 15 | static DigitalIn taster1 (PG_7); |
MarcoF89 | 7:a54c97795013 | 16 | static DigitalIn taster2 (PD_10); |
MarcoF89 | 7:a54c97795013 | 17 | static DigitalIn taster3 (PG_14); |
MarcoF89 | 7:a54c97795013 | 18 | static DigitalIn taster4 (PF_12); |
MarcoF89 | 6:27a09e8bebfb | 19 | |
MarcoF89 | 8:769ff3814355 | 20 | static DigitalOut db0(PC_8); |
MarcoF89 | 8:769ff3814355 | 21 | static DigitalOut db1(PC_9); |
MarcoF89 | 8:769ff3814355 | 22 | static DigitalOut db2(PC_10); |
MarcoF89 | 8:769ff3814355 | 23 | static DigitalOut db3(PC_11); |
MarcoF89 | 8:769ff3814355 | 24 | static DigitalOut db4(PC_12); |
MarcoF89 | 8:769ff3814355 | 25 | static DigitalOut db5(PC_13); |
MarcoF89 | 8:769ff3814355 | 26 | static DigitalOut db6(PC_14); |
MarcoF89 | 8:769ff3814355 | 27 | static DigitalOut db7(PC_15); |
MarcoF89 | 8:769ff3814355 | 28 | |
MarcoF89 | 9:9185d37e061f | 29 | PwmOut Motor2 (PC_9); // Weiß |
MarcoF89 | 9:9185d37e061f | 30 | PwmOut Motor1 (PC_8); // Schwarz |
MarcoF89 | 9:9185d37e061f | 31 | PwmOut Motor3 (PC_6); // Grau |
MarcoF89 | 9:9185d37e061f | 32 | PwmOut Motor4 (PB_9); // Blau |
MarcoF89 | 9:9185d37e061f | 33 | // Gelb und Orange Vcc +5V |
MarcoF89 | 9:9185d37e061f | 34 | // Gnd Rot |
MarcoF89 | 9:9185d37e061f | 35 | |
MarcoF89 | 8:769ff3814355 | 36 | |
MarcoF89 | 6:27a09e8bebfb | 37 | int main() |
MarcoF89 | 6:27a09e8bebfb | 38 | { |
MarcoF89 | 9:9185d37e061f | 39 | |
MarcoF89 | 9:9185d37e061f | 40 | float winkel1, winkel2; |
MarcoF89 | 9:9185d37e061f | 41 | |
MarcoF89 | 6:27a09e8bebfb | 42 | initialisierung_gyro(); |
MarcoF89 | 6:27a09e8bebfb | 43 | initialisierung_acc (); |
MarcoF89 | 9:9185d37e061f | 44 | pc.printf("\n\r"); |
MarcoF89 | 6:27a09e8bebfb | 45 | while(1) |
MarcoF89 | 6:27a09e8bebfb | 46 | { |
MarcoF89 | 9:9185d37e061f | 47 | #include "mbed.h" |
MarcoF89 | 9:9185d37e061f | 48 | |
MarcoF89 | 9:9185d37e061f | 49 | PwmOut PWM (PB_11); |
MarcoF89 | 9:9185d37e061f | 50 | AnalogIn poti (PA_6); |
MarcoF89 | 9:9185d37e061f | 51 | |
MarcoF89 | 9:9185d37e061f | 52 | |
MarcoF89 | 9:9185d37e061f | 53 | { |
MarcoF89 | 9:9185d37e061f | 54 | PWM = poti.read(); |
MarcoF89 | 9:9185d37e061f | 55 | pc.printf("%f\n\r", poti.read()); |
MarcoF89 | 9:9185d37e061f | 56 | } |
MarcoF89 | 9:9185d37e061f | 57 | |
MarcoF89 | 9:9185d37e061f | 58 | float x = aktuell_acc_x (); |
MarcoF89 | 9:9185d37e061f | 59 | float z = aktuell_acc_z (); |
MarcoF89 | 9:9185d37e061f | 60 | winkel1 = (((float)atan2(x, z))); |
MarcoF89 | 9:9185d37e061f | 61 | float y = aktuell_acc_y (); |
MarcoF89 | 9:9185d37e061f | 62 | winkel2 = (((float)atan2(y, z))); |
MarcoF89 | 9:9185d37e061f | 63 | |
MarcoF89 | 9:9185d37e061f | 64 | |
MarcoF89 | 9:9185d37e061f | 65 | pc.printf("%4.2f\t\t\t%4.2f\t\r",winkel1*360/6.28, winkel2*360/6.28); |
MarcoF89 | 6:27a09e8bebfb | 66 | } |
MarcoF89 | 6:27a09e8bebfb | 67 | } |