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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 25:371af8d95c69
- Parent:
- 24:7f14b70fc9ef
- Child:
- 26:abb0cc9a1dd2
--- a/main.cpp Mon Apr 08 11:03:25 2019 +0100 +++ b/main.cpp Wed Jan 29 18:35:18 2020 +0000 @@ -1,12 +1,20 @@ #include "mbed.h" - -DigitalOut myled(LED1); +#include <iostream> +AnalogIn pot(PTB0); +PwmOut servo(PTE20); -int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); +int main() +{ + double val = 0; + servo.period(0.02); + while(1) + { + val = 0; + for(int i=0; i<200; i++){ + wait(0.0001); + val = val + pot.read(); + } + servo.pulsewidth(0.001+(val/200000)); + cout << (val/200) << endl; } }