mo mo
/
F3RC2019_HAND_SERVO
servo
Diff: main.cpp
- Revision:
- 1:3b148850fbb9
- Parent:
- 0:633c14df6aad
diff -r 633c14df6aad -r 3b148850fbb9 main.cpp --- a/main.cpp Sat Sep 14 09:15:51 2019 +0000 +++ b/main.cpp Sat Sep 14 09:18:40 2019 +0000 @@ -7,31 +7,34 @@ PwmOut s2 (PB_8); PwmOut s3 (PB_9); -int main(){ - +int main() +{ + vsc3.init(); - + s1.period_us(20000); s2.period_us(20000); s3.period_us(20000); - - while(1){ - - vsc3.poll(); - if(vsc3.read(PS_PAD::PAD_TRIANGLE)){ - s1.pulsewidth_us(300); - }else if(vsc3.read(PS_PAD::PAD_RIGHT)){ - s2.pulsewidth_us(500); - }else if(vsc3.read(PS_PAD::PAD_TOP)){ - s3.pulsewidth_us(500); - }else if(vsc3.read(PS_PAD::PAD_X)){ - s1.pulsewidth_us(2400); - }else; if(vsc3.read(PS_PAD::PAD_LEFT)){ - s2.pulsewidth_us(2400); - }else; if(vsc3.read(PS_PAD::PAD_BOTTOM)){ - s3.pulsewidth_us(2400); - }else; - wait(0.05); - + + while(1) { + + vsc3.poll(); + if(vsc3.read(PS_PAD::PAD_TRIANGLE)) { + s1.pulsewidth_us(300); + } else if(vsc3.read(PS_PAD::PAD_RIGHT)) { + s2.pulsewidth_us(500); + } else if(vsc3.read(PS_PAD::PAD_TOP)) { + s3.pulsewidth_us(500); + } else if(vsc3.read(PS_PAD::PAD_X)) { + s1.pulsewidth_us(2400); + } else; + if(vsc3.read(PS_PAD::PAD_LEFT)) { + s2.pulsewidth_us(2400); + } else; + if(vsc3.read(PS_PAD::PAD_BOTTOM)) { + s3.pulsewidth_us(2400); + } else; + wait(0.05); + } } \ No newline at end of file