![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
nana
Diff: coffre.cpp
- Revision:
- 0:5755bf39c144
diff -r 000000000000 -r 5755bf39c144 coffre.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/coffre.cpp Fri May 18 14:04:05 2018 +0000 @@ -0,0 +1,59 @@ +#include"mbed.h" + + + +PwmOut servo (p21); +BusIn digicode(p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16); + + +void fermer() +{ + servo.pulsewidth(0.194); +} + +void ouvrir() +{ + + servo.pulsewidth(0.178); +} + +int lireval(){ + int val; + if(digicode.read()==0){ + val=-3; + } + if(digicode.read()==2){ + val=7; + } + if(digicode.read()==4){ + val=4; + } + if(digicode.read()==8){ + val=1; + } + if(digicode.read()==16){ + val=0; + } + if(digicode.read()==32){ + val=8; + } + if(digicode.read()==64){ + val=5; + } + if(digicode.read()==128){ + val=2; + } + if(digicode.read()==256){ + val=-2; + } + if(digicode.read()==512){ + val=9; + } + if(digicode.read()==1024){ + val=6; + } + if(digicode.read()==2048){ + val=3; + } + return val; +} \ No newline at end of file