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: FastPWM mbed QEI biquadFilter HIDScope MODSERIAL
main.cpp@4:0c27632b453a, 2018-09-25 (annotated)
- Committer:
- Ramonwaninge
- Date:
- Tue Sep 25 15:27:39 2018 +0000
- Revision:
- 4:0c27632b453a
- Parent:
- 3:d39285fdd103
- Child:
- 5:047db32db712
Draait rechtsom door potmeter
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ramonwaninge | 0:3ea1bbfbeaae | 1 | #include "mbed.h" |
Ramonwaninge | 0:3ea1bbfbeaae | 2 | #include "FastPWM.h" |
Ramonwaninge | 0:3ea1bbfbeaae | 3 | |
Ramonwaninge | 0:3ea1bbfbeaae | 4 | |
Ramonwaninge | 0:3ea1bbfbeaae | 5 | Ticker motor; |
Ramonwaninge | 0:3ea1bbfbeaae | 6 | |
Ramonwaninge | 0:3ea1bbfbeaae | 7 | FastPWM pin5(D5); |
Ramonwaninge | 4:0c27632b453a | 8 | AnalogIn pot1(A1); |
Ramonwaninge | 4:0c27632b453a | 9 | //AnalogOut pot2(A2); |
Ramonwaninge | 3:d39285fdd103 | 10 | DigitalOut pin4(D4); |
Ramonwaninge | 4:0c27632b453a | 11 | //float u = pot1; |
Ramonwaninge | 2:d8a552d1d33a | 12 | |
Ramonwaninge | 3:d39285fdd103 | 13 | void draai(){ |
Ramonwaninge | 4:0c27632b453a | 14 | float u = pot1; |
Ramonwaninge | 4:0c27632b453a | 15 | |
Ramonwaninge | 4:0c27632b453a | 16 | //if (u>0){ |
Ramonwaninge | 4:0c27632b453a | 17 | // pin4 = true; |
Ramonwaninge | 4:0c27632b453a | 18 | // } |
Ramonwaninge | 4:0c27632b453a | 19 | // else if(u<0){ |
Ramonwaninge | 4:0c27632b453a | 20 | // pin4 = false; |
Ramonwaninge | 4:0c27632b453a | 21 | // } |
Ramonwaninge | 4:0c27632b453a | 22 | pin4 = true;// u > 0.0f; |
Ramonwaninge | 3:d39285fdd103 | 23 | pin5 = fabs(u); |
Ramonwaninge | 3:d39285fdd103 | 24 | } |
Ramonwaninge | 1:e40e981acbf1 | 25 | int main(){ |
Ramonwaninge | 1:e40e981acbf1 | 26 | |
Ramonwaninge | 1:e40e981acbf1 | 27 | pin5.period_us(60); |
Ramonwaninge | 3:d39285fdd103 | 28 | motor.attach(draai, 0.001); |
Ramonwaninge | 3:d39285fdd103 | 29 | while(true){ |
Ramonwaninge | 4:0c27632b453a | 30 | |
Ramonwaninge | 3:d39285fdd103 | 31 | } |
Ramonwaninge | 0:3ea1bbfbeaae | 32 | } |