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.
main.cpp@11:5e955cf303ab, 2018-10-31 (annotated)
- Committer:
- Nicolaemf
- Date:
- Wed Oct 31 14:21:58 2018 +0000
- Revision:
- 11:5e955cf303ab
- Parent:
- 6:b476699ac7d4
PWM on both sides;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nicolaemf | 0:30183794e491 | 1 | #include "mbed.h" |
Nicolaemf | 11:5e955cf303ab | 2 | |
Nicolaemf | 11:5e955cf303ab | 3 | Serial pc(USBTX, USBRX); // tx, rx |
Nicolaemf | 4:9827e5952222 | 4 | |
Nicolaemf | 11:5e955cf303ab | 5 | PwmOut myled(LED1); |
Nicolaemf | 11:5e955cf303ab | 6 | PwmOut motorRight(PTD0); |
Nicolaemf | 11:5e955cf303ab | 7 | PwmOut motorLeft(PTD5); |
Nicolaemf | 4:9827e5952222 | 8 | |
Nicolaemf | 11:5e955cf303ab | 9 | //PwmOut pwm1(PTD0); |
Nicolaemf | 11:5e955cf303ab | 10 | AnalogIn potInput(PTB0); |
Nicolaemf | 11:5e955cf303ab | 11 | float storeInput; |
Nicolaemf | 11:5e955cf303ab | 12 | |
Nicolaemf | 0:30183794e491 | 13 | |
Nicolaemf | 0:30183794e491 | 14 | int main() { |
Nicolaemf | 11:5e955cf303ab | 15 | |
Nicolaemf | 11:5e955cf303ab | 16 | myled = 0.1; |
Nicolaemf | 11:5e955cf303ab | 17 | |
Nicolaemf | 0:30183794e491 | 18 | while(1) { |
Nicolaemf | 11:5e955cf303ab | 19 | |
Nicolaemf | 11:5e955cf303ab | 20 | myled = myled + 0.1; |
Nicolaemf | 11:5e955cf303ab | 21 | |
Nicolaemf | 11:5e955cf303ab | 22 | if(myled >= 1){ |
Nicolaemf | 11:5e955cf303ab | 23 | myled = 0; |
Nicolaemf | 11:5e955cf303ab | 24 | } |
Nicolaemf | 11:5e955cf303ab | 25 | storeInput = potInput.read(); |
Nicolaemf | 11:5e955cf303ab | 26 | motorRight = storeInput; |
Nicolaemf | 11:5e955cf303ab | 27 | motorLeft = (storeInput * -1.0) + 1.0; |
Nicolaemf | 11:5e955cf303ab | 28 | |
Nicolaemf | 11:5e955cf303ab | 29 | pc.printf("%f\n", storeInput); |
Nicolaemf | 11:5e955cf303ab | 30 | |
Nicolaemf | 11:5e955cf303ab | 31 | wait(0.1); |
Nicolaemf | 11:5e955cf303ab | 32 | |
Nicolaemf | 11:5e955cf303ab | 33 | } |
Nicolaemf | 11:5e955cf303ab | 34 | |
Nicolaemf | 0:30183794e491 | 35 | } |
Nicolaemf | 11:5e955cf303ab | 36 |