Tests motors - increments one, decrements the other
Dependencies: mbed
Fork of FRDM-K64_PWM by
main.cpp@2:d861baf2b13b, 2015-03-23 (annotated)
- Committer:
- joshwilkins2013
- Date:
- Mon Mar 23 15:51:27 2015 +0000
- Revision:
- 2:d861baf2b13b
- Parent:
- 1:fd419b982c73
- Child:
- 3:8065a36c54ad
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 | |
Reimerguns | 1:fd419b982c73 | 10 | DigitalOut PinI3(PTD3); // pin 12 |
Reimerguns | 1:fd419b982c73 | 11 | DigitalOut PinI4(PTD1); // pin 13 |
Reimerguns | 1:fd419b982c73 | 12 | |
Reimerguns | 1:fd419b982c73 | 13 | int main() |
APanecatl | 0:24a5f9b6fd64 | 14 | { |
Reimerguns | 1:fd419b982c73 | 15 | PinI1 = PinI3 = 0; |
Reimerguns | 1:fd419b982c73 | 16 | PinI2 = PinI4 = 1; |
Reimerguns | 1:fd419b982c73 | 17 | PWM1.period_ms(255); |
Reimerguns | 1:fd419b982c73 | 18 | PWM2.period_ms(255); |
APanecatl | 0:24a5f9b6fd64 | 19 | int x; |
APanecatl | 0:24a5f9b6fd64 | 20 | x=1; |
APanecatl | 0:24a5f9b6fd64 | 21 | |
joshwilkins2013 | 2:d861baf2b13b | 22 | while(1){ |
APanecatl | 0:24a5f9b6fd64 | 23 | PWM1.pulsewidth_ms(x); |
Reimerguns | 1:fd419b982c73 | 24 | PWM2.pulsewidth_ms(x); |
APanecatl | 0:24a5f9b6fd64 | 25 | x=x+1; |
Reimerguns | 1:fd419b982c73 | 26 | wait(1); |
joshwilkins2013 | 2:d861baf2b13b | 27 | if(x==255) x=1; |
APanecatl | 0:24a5f9b6fd64 | 28 | } |
APanecatl | 0:24a5f9b6fd64 | 29 | } |