Dydaktyka
Dependencies: FastPWM mbed-src
Fork of 2015_04_17_quadro_bez_sterowania by
main.cpp@2:9e6ed6302c78, 2014-12-17 (annotated)
- Committer:
- Igor_W
- Date:
- Wed Dec 17 09:25:43 2014 +0000
- Revision:
- 2:9e6ed6302c78
- Parent:
- 1:5160ea45399b
- Child:
- 3:1425359662e4
ej
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:50d2b9c62765 | 1 | #include "mbed.h" |
mbedAustin | 1:5160ea45399b | 2 | |
Igor_W | 2:9e6ed6302c78 | 3 | #define PWM_period 2500 |
Igor_W | 2:9e6ed6302c78 | 4 | |
Igor_W | 2:9e6ed6302c78 | 5 | |
Igor_W | 2:9e6ed6302c78 | 6 | int valPWM1 = 1000; |
Igor_W | 2:9e6ed6302c78 | 7 | int valPWM2 = 1000; |
Igor_W | 2:9e6ed6302c78 | 8 | int valPWM3 = 1000; |
Igor_W | 2:9e6ed6302c78 | 9 | int valPWM4 = 1000; |
Igor_W | 2:9e6ed6302c78 | 10 | |
Igor_W | 2:9e6ed6302c78 | 11 | |
Igor_W | 2:9e6ed6302c78 | 12 | PwmOut motor1 (D10); |
Igor_W | 2:9e6ed6302c78 | 13 | PwmOut motor2 (D11); |
Igor_W | 2:9e6ed6302c78 | 14 | PwmOut motor3 (D12); |
Igor_W | 2:9e6ed6302c78 | 15 | PwmOut motor4 (D13); |
Igor_W | 2:9e6ed6302c78 | 16 | |
mbedAustin | 1:5160ea45399b | 17 | |
mbed_official | 0:50d2b9c62765 | 18 | int main() { |
Igor_W | 2:9e6ed6302c78 | 19 | |
Igor_W | 2:9e6ed6302c78 | 20 | motor1.period_us(PWM_period); |
Igor_W | 2:9e6ed6302c78 | 21 | motor2.period_us(PWM_period); |
Igor_W | 2:9e6ed6302c78 | 22 | motor3.period_us(PWM_period); |
Igor_W | 2:9e6ed6302c78 | 23 | motor4.period_us(PWM_period); |
Igor_W | 2:9e6ed6302c78 | 24 | |
Igor_W | 2:9e6ed6302c78 | 25 | while(1) { |
Igor_W | 2:9e6ed6302c78 | 26 | |
Igor_W | 2:9e6ed6302c78 | 27 | for (int i = 1000; i < 1500;i++) |
Igor_W | 2:9e6ed6302c78 | 28 | { |
Igor_W | 2:9e6ed6302c78 | 29 | |
Igor_W | 2:9e6ed6302c78 | 30 | valPWM1 = i; |
Igor_W | 2:9e6ed6302c78 | 31 | valPWM3 = i; |
Igor_W | 2:9e6ed6302c78 | 32 | valPWM2 = 2500 - i; |
Igor_W | 2:9e6ed6302c78 | 33 | valPWM4 = 2500 - i; |
Igor_W | 2:9e6ed6302c78 | 34 | |
Igor_W | 2:9e6ed6302c78 | 35 | motor1.pulsewidth_ms(valPWM1); |
Igor_W | 2:9e6ed6302c78 | 36 | motor2.pulsewidth_ms(valPWM2); |
Igor_W | 2:9e6ed6302c78 | 37 | motor3.pulsewidth_ms(valPWM3); |
Igor_W | 2:9e6ed6302c78 | 38 | motor4.pulsewidth_ms(valPWM4); |
Igor_W | 2:9e6ed6302c78 | 39 | } |
Igor_W | 2:9e6ed6302c78 | 40 | |
Igor_W | 2:9e6ed6302c78 | 41 | } |
mbed_official | 0:50d2b9c62765 | 42 | } |