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.
Revision 0:96da12aef31f, committed 2020-11-27
- Comitter:
- Marcelocostanzo
- Date:
- Fri Nov 27 14:12:47 2020 +0000
- Commit message:
- V1 FUNCIONANDO
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Nov 27 14:12:47 2020 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+
+PwmOut myservo(D6);
+AnalogIn pot(A0);
+Serial pc(USBTX, USBRX); // tx, rx
+
+float Map (float inVal, float inMin, float inMax, float outMin, float outMax);
+
+float i=0.0f, x=0.0f;
+
+int main() {
+
+ myservo.period(0.02f);
+
+ //Required ESC Calibration/Arming sequence
+
+ //sends longest and shortest PWM pulse to learn and arm at power on
+ myservo = 0.1;
+ wait(2.5);
+ myservo = 0.05;
+ wait(2.5);
+ myservo = 0.075;
+ wait(2.5);
+
+
+ while(1){
+ x = pot.read();
+ i = Map(x, 0.0, 1.0, 0.05, 0.1);
+ myservo.write(i);
+ pc.printf("control %f\n\r",i);
+ wait(0.2);
+ }
+}
+
+float Map (float inVal, float inMin, float inMax, float outMin, float outMax)
+{
+ return ( (inVal - inMin)*(outMax - outMin)/(inMax - inMin) + outMin );
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Nov 27 14:12:47 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee \ No newline at end of file