Chris Elsholz / Mbed 2 deprecated Quadrocopter

Dependencies:   mbed TextLCD

Fork of Quadrocopter by Marco Friedmann

main.cpp

Committer:
MarcoF89
Date:
2017-08-08
Revision:
10:16ca5e9ee0dc
Parent:
9:9185d37e061f
Child:
11:8457b851e3e1

File content as of revision 10:16ca5e9ee0dc:

#include "mbed.h"
#include "stdio.h"
#include <Timer.h>
#include "messen.h"

static Serial pc(SERIAL_TX, SERIAL_RX);
static SPI spi(PE_6,PE_5,PE_2);  //mosi,miso,sclk
static DigitalOut ncs(PE_4);    //ssel

static AnalogIn poti_1 (PF_3);
static AnalogIn poti_2 (PF_10);
static AnalogIn poti_3 (PF_4);
static AnalogIn poti_4 (PF_5);

static DigitalIn taster1 (PG_7);
static DigitalIn taster2 (PD_10);
static DigitalIn taster3 (PG_14);
static DigitalIn taster4 (PF_12);

static DigitalOut db0(PC_8);
static DigitalOut db1(PC_9);
static DigitalOut db2(PC_10);
static DigitalOut db3(PC_11);
static DigitalOut db4(PC_12);
static DigitalOut db5(PC_13);
static DigitalOut db6(PC_14);
static DigitalOut db7(PC_15);

static PwmOut Motor2 (PC_9);       //  Weiß
static PwmOut Motor1 (PC_8);       //  Schwarz
static PwmOut Motor3 (PC_6);       //  Grau
static PwmOut Motor4 (PB_9);       //  Blau
                                //  Gelb und Orange Vcc +5V 
                                //  Gnd Rot


int main()
{ 

Motor1.period_ms(2);
Motor2.period_ms(2);
Motor3.period_ms(2);
Motor4.period_ms(2);


pc.printf("\n\r");
    while(1)
    {   
        Motor3.pulsewidth_us(poti_1.read_u16()*0.015305732*2);
        pc.printf("Poti = %2.2f\r",poti_1.read_u16()*0.015305732); 
    }
}





/*
        float x = aktuell_acc_x ();
        float z = aktuell_acc_z ();
        winkel1 = (((float)atan2(x, z)));
        float y = aktuell_acc_y ();
        winkel2 = (((float)atan2(y, z)));
        
        pc.printf("%4.2f\t\t\t%4.2f\t\r",winkel1*360/6.28, winkel2*360/6.28);*/