Tests motors - increments one, decrements the other
Dependencies: mbed
Fork of FRDM-K64_PWM by
main.cpp@1:fd419b982c73, 2015-03-23 (annotated)
- Committer:
- Reimerguns
- Date:
- Mon Mar 23 15:45:46 2015 +0000
- Revision:
- 1:fd419b982c73
- Parent:
- 0:24a5f9b6fd64
- Child:
- 2:d861baf2b13b
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
APanecatl | 0:24a5f9b6fd64 | 1 | #include "mbed.h" |
APanecatl | 0:24a5f9b6fd64 | 2 | |
APanecatl | 0:24a5f9b6fd64 | 3 | //PWM output channel |
Reimerguns | 1:fd419b982c73 | 4 | PwmOut PWM1(PTD0); |
Reimerguns | 1:fd419b982c73 | 5 | PwmOut PWM2(PTC4); |
Reimerguns | 1:fd419b982c73 | 6 | |
Reimerguns | 1:fd419b982c73 | 7 | DigitalOut PinI1(PTA0); //pin 8 |
Reimerguns | 1:fd419b982c73 | 8 | DigitalOut PinI2(PTD2); // pin 11 |
Reimerguns | 1:fd419b982c73 | 9 | |
APanecatl | 0:24a5f9b6fd64 | 10 | |
Reimerguns | 1:fd419b982c73 | 11 | DigitalOut PinI3(PTD3); // pin 12 |
Reimerguns | 1:fd419b982c73 | 12 | DigitalOut PinI4(PTD1); // pin 13 |
Reimerguns | 1:fd419b982c73 | 13 | |
Reimerguns | 1:fd419b982c73 | 14 | int main() |
APanecatl | 0:24a5f9b6fd64 | 15 | { |
Reimerguns | 1:fd419b982c73 | 16 | PinI1 = PinI3 = 0; |
Reimerguns | 1:fd419b982c73 | 17 | PinI2 = PinI4 = 1; |
Reimerguns | 1:fd419b982c73 | 18 | PWM1.period_ms(255); |
Reimerguns | 1:fd419b982c73 | 19 | PWM2.period_ms(255); |
APanecatl | 0:24a5f9b6fd64 | 20 | int x; |
APanecatl | 0:24a5f9b6fd64 | 21 | x=1; |
APanecatl | 0:24a5f9b6fd64 | 22 | |
APanecatl | 0:24a5f9b6fd64 | 23 | while(1) |
APanecatl | 0:24a5f9b6fd64 | 24 | { |
APanecatl | 0:24a5f9b6fd64 | 25 | PWM1.pulsewidth_ms(x); |
Reimerguns | 1:fd419b982c73 | 26 | PWM2.pulsewidth_ms(x); |
APanecatl | 0:24a5f9b6fd64 | 27 | x=x+1; |
Reimerguns | 1:fd419b982c73 | 28 | wait(1); |
Reimerguns | 1:fd419b982c73 | 29 | if(x==255) |
APanecatl | 0:24a5f9b6fd64 | 30 | { |
APanecatl | 0:24a5f9b6fd64 | 31 | x=1; |
APanecatl | 0:24a5f9b6fd64 | 32 | } |
APanecatl | 0:24a5f9b6fd64 | 33 | } |
APanecatl | 0:24a5f9b6fd64 | 34 | } |