Regenerating PPM signal based on distances from ultrasonic sensors, ESP8266 for connectin via wifi. Autonomous quadcopter behaviour, autonomou height holding. Flying direction based on front and back ultrasonic sensors.
Dependencies: ConfigFile HCSR04 PID PPM2 mbed-rtos mbed
Diff: main.cpp
- Revision:
- 0:5cefadfd5898
- Child:
- 1:3a5a074b39e0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 22 11:29:54 2017 +0000 @@ -0,0 +1,67 @@ +#include "mbed.h" +#include "PPMOut.h" +#include "PPMIn.h" +//#include "PPMIn.h" +//#include "ultrasonic.h" +//#include "MyPID.h" + + +#define AUX1 4 +#define PIEZZO_START 0.1 +#define PIEZZO_STOP 0.0 +#define PPMOUT_CHANNELS 6 +#define PPMIN_CHANNELS 8 + +Serial pc(USBTX, USBRX); // tx, rx +PpmOut ppmOut(p26, PPMOUT_CHANNELS); +PpmIn ppmIn(p21); + + +uint16_t ppmOutChannelsValue[PPMOUT_CHANNELS]; +uint16_t ppmInChannelsValue[PPMIN_CHANNELS]; + +//FUNCTIONS +void print_ppmOut(void); +void print_ppmIn(void); + +int main(){ + + while(1){ + print_ppmIn(); + print_ppmOut(); + + if(ppmIn.rise_captured()){ + pc.printf("Rise captured \n\r"); + } + + } + +} + + + + + + + + + + +void print_ppmOut(){ + ppmOut.getAllChannels(ppmOutChannelsValue); + + for(uint8_t channel= 0; channel < PPMOUT_CHANNELS; channel++){ + pc.printf("PPM Out Channel %d: %d \n\r", channel, ppmOutChannelsValue[channel]); + } +} + +void print_ppmIn(){ + ppmIn.getAllChannels(ppmInChannelsValue); + for(uint8_t channel= 0; channel < PPMIN_CHANNELS; channel++){ + pc.printf("PPM In Channel %d: %d \n\r", channel, ppmInChannelsValue[channel]); + } + pc.printf("\n\r"); +} + + +