servo

Dependencies:   mbed PS_PAD

Committer:
imoha
Date:
Sat Sep 14 09:18:40 2019 +0000
Revision:
1:3b148850fbb9
Parent:
0:633c14df6aad
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 1:3b148850fbb9 10 int main()
imoha 1:3b148850fbb9 11 {
imoha 1:3b148850fbb9 12
imoha 0:633c14df6aad 13 vsc3.init();
imoha 1:3b148850fbb9 14
imoha 0:633c14df6aad 15 s1.period_us(20000);
imoha 0:633c14df6aad 16 s2.period_us(20000);
imoha 0:633c14df6aad 17 s3.period_us(20000);
imoha 1:3b148850fbb9 18
imoha 1:3b148850fbb9 19 while(1) {
imoha 1:3b148850fbb9 20
imoha 1:3b148850fbb9 21 vsc3.poll();
imoha 1:3b148850fbb9 22 if(vsc3.read(PS_PAD::PAD_TRIANGLE)) {
imoha 1:3b148850fbb9 23 s1.pulsewidth_us(300);
imoha 1:3b148850fbb9 24 } else if(vsc3.read(PS_PAD::PAD_RIGHT)) {
imoha 1:3b148850fbb9 25 s2.pulsewidth_us(500);
imoha 1:3b148850fbb9 26 } else if(vsc3.read(PS_PAD::PAD_TOP)) {
imoha 1:3b148850fbb9 27 s3.pulsewidth_us(500);
imoha 1:3b148850fbb9 28 } else if(vsc3.read(PS_PAD::PAD_X)) {
imoha 1:3b148850fbb9 29 s1.pulsewidth_us(2400);
imoha 1:3b148850fbb9 30 } else;
imoha 1:3b148850fbb9 31 if(vsc3.read(PS_PAD::PAD_LEFT)) {
imoha 1:3b148850fbb9 32 s2.pulsewidth_us(2400);
imoha 1:3b148850fbb9 33 } else;
imoha 1:3b148850fbb9 34 if(vsc3.read(PS_PAD::PAD_BOTTOM)) {
imoha 1:3b148850fbb9 35 s3.pulsewidth_us(2400);
imoha 1:3b148850fbb9 36 } else;
imoha 1:3b148850fbb9 37 wait(0.05);
imoha 1:3b148850fbb9 38
imoha 0:633c14df6aad 39 }
imoha 0:633c14df6aad 40 }