servo

Dependencies:   mbed PS_PAD

Committer:
imoha
Date:
Sat Sep 14 09:15:51 2019 +0000
Revision:
0:633c14df6aad
Child:
1:3b148850fbb9
servo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
imoha 0:633c14df6aad 1 #include "mbed.h"
imoha 0:633c14df6aad 2 #include "PS_PAD.h"
imoha 0:633c14df6aad 3
imoha 0:633c14df6aad 4 PS_PAD vsc3(PA_7,PA_6,PA_5,PB_6);
imoha 0:633c14df6aad 5
imoha 0:633c14df6aad 6 PwmOut s1 (PC_9);
imoha 0:633c14df6aad 7 PwmOut s2 (PB_8);
imoha 0:633c14df6aad 8 PwmOut s3 (PB_9);
imoha 0:633c14df6aad 9
imoha 0:633c14df6aad 10 int main(){
imoha 0:633c14df6aad 11
imoha 0:633c14df6aad 12 vsc3.init();
imoha 0:633c14df6aad 13
imoha 0:633c14df6aad 14 s1.period_us(20000);
imoha 0:633c14df6aad 15 s2.period_us(20000);
imoha 0:633c14df6aad 16 s3.period_us(20000);
imoha 0:633c14df6aad 17
imoha 0:633c14df6aad 18 while(1){
imoha 0:633c14df6aad 19
imoha 0:633c14df6aad 20 vsc3.poll();
imoha 0:633c14df6aad 21 if(vsc3.read(PS_PAD::PAD_TRIANGLE)){
imoha 0:633c14df6aad 22 s1.pulsewidth_us(300);
imoha 0:633c14df6aad 23 }else if(vsc3.read(PS_PAD::PAD_RIGHT)){
imoha 0:633c14df6aad 24 s2.pulsewidth_us(500);
imoha 0:633c14df6aad 25 }else if(vsc3.read(PS_PAD::PAD_TOP)){
imoha 0:633c14df6aad 26 s3.pulsewidth_us(500);
imoha 0:633c14df6aad 27 }else if(vsc3.read(PS_PAD::PAD_X)){
imoha 0:633c14df6aad 28 s1.pulsewidth_us(2400);
imoha 0:633c14df6aad 29 }else; if(vsc3.read(PS_PAD::PAD_LEFT)){
imoha 0:633c14df6aad 30 s2.pulsewidth_us(2400);
imoha 0:633c14df6aad 31 }else; if(vsc3.read(PS_PAD::PAD_BOTTOM)){
imoha 0:633c14df6aad 32 s3.pulsewidth_us(2400);
imoha 0:633c14df6aad 33 }else;
imoha 0:633c14df6aad 34 wait(0.05);
imoha 0:633c14df6aad 35
imoha 0:633c14df6aad 36 }
imoha 0:633c14df6aad 37 }