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.
main.cpp
00001 #include "mbed.h" 00002 #include "Servo.h" 00003 #include "Timer.h" 00004 00005 DigitalIn pixhawk(LED1); 00006 Servo gas(p21); 00007 Servo brake(p22); 00008 Timer timer; 00009 float delta; 00010 00011 int main() 00012 { 00013 while(1) { 00014 // read pulseIn 00015 while (!pixhawk); // wait for high 1 or -1 00016 timer.reset(); 00017 timer.start(); 00018 while (pixhawk); // wait for low 00019 timer.stop(); 00020 delta = timer.read_us(); //provides pwm on time in microseconds 00021 00022 if(delta > 0) { 00023 gas = delta*1000; // convert to PWM signal for gas 00024 } else if(delta <= 0 && delta > 0.33) { 00025 brake = -.4; // light braking 00026 } else { 00027 brake = -1; // full brake 00028 } 00029 } 00030 }
Generated on Mon Oct 17 2022 03:18:09 by
1.7.2