高石 龍河
/
Servomotor_example_2
use servo motor with volume
Revision 0:0fe3ec1dc2fc, committed 2019-04-06
- Comitter:
- Ryuga
- Date:
- Sat Apr 06 09:38:55 2019 +0000
- Commit message:
- create; ; this is new program to use servo motor with volume for first-year-student;
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 |
diff -r 000000000000 -r 0fe3ec1dc2fc main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Apr 06 09:38:55 2019 +0000 @@ -0,0 +1,13 @@ +#include "mbed.h" + +PwmOut servo(D10); +AnalogIn input(D6); + +int main() { + servo.period(0.020); + while(1) { + float offset = input.read() * 0.001f; + servo.pulsewidth(0.001f + offset); + wait(0.25); + } +}
diff -r 000000000000 -r 0fe3ec1dc2fc mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Apr 06 09:38:55 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file