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
main.cpp@25:371af8d95c69, 2020-01-29 (annotated)
- Committer:
- jtho1327
- Date:
- Wed Jan 29 18:35:18 2020 +0000
- Revision:
- 25:371af8d95c69
- Parent:
- 24:7f14b70fc9ef
- Child:
- 26:abb0cc9a1dd2
servo motion test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan | 0:7dec7e9ac085 | 1 | #include "mbed.h" |
jtho1327 | 25:371af8d95c69 | 2 | #include <iostream> |
jtho1327 | 25:371af8d95c69 | 3 | AnalogIn pot(PTB0); |
jtho1327 | 25:371af8d95c69 | 4 | PwmOut servo(PTE20); |
dan | 0:7dec7e9ac085 | 5 | |
jtho1327 | 25:371af8d95c69 | 6 | int main() |
jtho1327 | 25:371af8d95c69 | 7 | { |
jtho1327 | 25:371af8d95c69 | 8 | double val = 0; |
jtho1327 | 25:371af8d95c69 | 9 | servo.period(0.02); |
jtho1327 | 25:371af8d95c69 | 10 | while(1) |
jtho1327 | 25:371af8d95c69 | 11 | { |
jtho1327 | 25:371af8d95c69 | 12 | val = 0; |
jtho1327 | 25:371af8d95c69 | 13 | for(int i=0; i<200; i++){ |
jtho1327 | 25:371af8d95c69 | 14 | wait(0.0001); |
jtho1327 | 25:371af8d95c69 | 15 | val = val + pot.read(); |
jtho1327 | 25:371af8d95c69 | 16 | } |
jtho1327 | 25:371af8d95c69 | 17 | servo.pulsewidth(0.001+(val/200000)); |
jtho1327 | 25:371af8d95c69 | 18 | cout << (val/200) << endl; |
stevep | 4:81cea7a352b0 | 19 | } |
dan | 0:7dec7e9ac085 | 20 | } |