Tests motors - increments one, decrements the other

Dependencies:   mbed

Fork of FRDM-K64_PWM by Augusto Panecatl

Committer:
joshwilkins2013
Date:
Tue Mar 31 22:37:36 2015 +0000
Revision:
3:8065a36c54ad
Parent:
2:d861baf2b13b

        

Who changed what in which revision?

UserRevisionLine numberNew 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 {
joshwilkins2013 3:8065a36c54ad 15 PinI1 = PinI3 = 1;
joshwilkins2013 3:8065a36c54ad 16 PinI2 = PinI4 = 0;
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;
joshwilkins2013 3:8065a36c54ad 21 int y;
joshwilkins2013 3:8065a36c54ad 22 y=255;
APanecatl 0:24a5f9b6fd64 23
joshwilkins2013 2:d861baf2b13b 24 while(1){
APanecatl 0:24a5f9b6fd64 25 PWM1.pulsewidth_ms(x);
joshwilkins2013 3:8065a36c54ad 26 PWM2.pulsewidth_ms(y);
joshwilkins2013 3:8065a36c54ad 27 x++;
joshwilkins2013 3:8065a36c54ad 28 y--;
joshwilkins2013 3:8065a36c54ad 29 wait(.25);
joshwilkins2013 2:d861baf2b13b 30 if(x==255) x=1;
joshwilkins2013 3:8065a36c54ad 31 if(y==0) y=255;
APanecatl 0:24a5f9b6fd64 32 }
APanecatl 0:24a5f9b6fd64 33 }