![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
the fish that looks like a jet
Dependencies: ADXL345 ADXL345_I2C IMUfilter ITG3200 mbed Servo
main.cpp
- Committer:
- rkk
- Date:
- 2014-01-31
- Revision:
- 9:8dd7a76756e2
- Parent:
- 8:0574a5db1fc4
- Child:
- 10:d9f1037f0cb0
File content as of revision 9:8dd7a76756e2:
#include "mbed.h" #include "motor_controller.h" #include "guardian.h" //#include "IMU.h" #include "Servo.h" //#include "rtos.h" //#include "PwmReader.h" #include "PwmIn.h" #define VOLUME_MAX 0.4 #define VOLUME_MIN 0.2 #define FREQUENCY_MAX 0.4 #define FREQUENCY_MIN 0.2 #define RUDDER_MAX 0.4 #define RUDDER_MIN 0.2 #define SIZE_ARRAY 500 bool quit=false; //InterruptIn event(p16); PololuMController mcon(p22, p6, p5); //Servo servo(p21); //Guardian ap(p21, p23, p24, p25, p26, p26); //Serial xbee(p13, p14); Serial pc(USBTX, USBRX); PwmIn ch3(p16,0.054,0.092); PwmIn ch6(p15,0.055,0.092); Timer t; float throttle, frequency, rudder; int main() { //ap.calibrate(); //ap.set2D(); //ap.setoff(); t.start(); while(t.read() < 500) { float vol_norm=ch6.dutycyclescaledup(); float freq_norm=ch3.dutycyclescaledup(); pc.printf("channel 3: %f, channel 6: %f\n", vol_norm, freq_norm); //mcon.drive_rectangular(t.read(), vol_norm*freq_norm, 3*freq_norm); //mcon.drive_sinusoidal(t.read(), vol_norm*freq_norm, 3*freq_norm); mcon.drive_sinusoidal(t.read(), vol_norm*freq_norm, 3*freq_norm); //pc.printf("time: %f\n\r", t.read()); //pc.printf("throttle: %f frequency: %f rudder: %f\n\r",throttle,frequency,rudder); wait_ms(20); } t.stop(); }