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 MotorLab3Code
main.cpp@0:cb571e42343c, 2019-01-30 (annotated)
- Committer:
- rjs718
- Date:
- Wed Jan 30 21:05:23 2019 +0000
- Revision:
- 0:cb571e42343c
- Child:
- 1:5b2bc7ec7b14
ghjk
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| rjs718 | 0:cb571e42343c | 1 | #include "mbed.h" |
| rjs718 | 0:cb571e42343c | 2 | #include <iostream> |
| rjs718 | 0:cb571e42343c | 3 | Serial pc(USBTX, USBRX); |
| rjs718 | 0:cb571e42343c | 4 | |
| rjs718 | 0:cb571e42343c | 5 | AnalogIn AI_in(PTB0); |
| rjs718 | 0:cb571e42343c | 6 | PwmOut PWM_out(PTE20); |
| rjs718 | 0:cb571e42343c | 7 | |
| rjs718 | 0:cb571e42343c | 8 | float SP; |
| rjs718 | 0:cb571e42343c | 9 | float DC; |
| rjs718 | 0:cb571e42343c | 10 | |
| rjs718 | 0:cb571e42343c | 11 | int main() { |
| rjs718 | 0:cb571e42343c | 12 | PWM_out.period(.05); |
| rjs718 | 0:cb571e42343c | 13 | |
| rjs718 | 0:cb571e42343c | 14 | while(1) { |
| rjs718 | 0:cb571e42343c | 15 | SP=AI_in; |
| rjs718 | 0:cb571e42343c | 16 | DC=SP / 3.3; |
| rjs718 | 0:cb571e42343c | 17 | PWM_out=DC * 100; |
| rjs718 | 0:cb571e42343c | 18 | cout <<PWM_out.read() << endl; |
| rjs718 | 0:cb571e42343c | 19 | |
| rjs718 | 0:cb571e42343c | 20 | |
| rjs718 | 0:cb571e42343c | 21 | } |
| rjs718 | 0:cb571e42343c | 22 | } |