oki

Dependencies:   mbed

Fork of ProjetInfo2_Multi by julien bitoun

Committer:
thomasstrcic
Date:
Fri Jun 01 11:36:44 2018 +0000
Revision:
2:ae058dfdebac
Parent:
0:5755bf39c144
Child:
3:98f5de1dd010
Child:
4:23e955d622f9
suceez moi; ; ; ; ; ; ; ; ; ; ; ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jujuonthebeat 0:5755bf39c144 1 #include"mbed.h"
jujuonthebeat 0:5755bf39c144 2
jujuonthebeat 0:5755bf39c144 3
jujuonthebeat 0:5755bf39c144 4 BusIn digicode(p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16);
thomasstrcic 2:ae058dfdebac 5 DigitalOut s(p17);
thomasstrcic 2:ae058dfdebac 6 Timer t;
thomasstrcic 2:ae058dfdebac 7 Timer t11;
jujuonthebeat 0:5755bf39c144 8
jujuonthebeat 0:5755bf39c144 9 int lireval(){
jujuonthebeat 0:5755bf39c144 10 int val;
jujuonthebeat 0:5755bf39c144 11 if(digicode.read()==0){
jujuonthebeat 0:5755bf39c144 12 val=-3;
jujuonthebeat 0:5755bf39c144 13 }
jujuonthebeat 0:5755bf39c144 14 if(digicode.read()==2){
jujuonthebeat 0:5755bf39c144 15 val=7;
jujuonthebeat 0:5755bf39c144 16 }
jujuonthebeat 0:5755bf39c144 17 if(digicode.read()==4){
jujuonthebeat 0:5755bf39c144 18 val=4;
jujuonthebeat 0:5755bf39c144 19 }
jujuonthebeat 0:5755bf39c144 20 if(digicode.read()==8){
jujuonthebeat 0:5755bf39c144 21 val=1;
jujuonthebeat 0:5755bf39c144 22 }
jujuonthebeat 0:5755bf39c144 23 if(digicode.read()==16){
jujuonthebeat 0:5755bf39c144 24 val=0;
jujuonthebeat 0:5755bf39c144 25 }
jujuonthebeat 0:5755bf39c144 26 if(digicode.read()==32){
jujuonthebeat 0:5755bf39c144 27 val=8;
jujuonthebeat 0:5755bf39c144 28 }
jujuonthebeat 0:5755bf39c144 29 if(digicode.read()==64){
jujuonthebeat 0:5755bf39c144 30 val=5;
jujuonthebeat 0:5755bf39c144 31 }
jujuonthebeat 0:5755bf39c144 32 if(digicode.read()==128){
jujuonthebeat 0:5755bf39c144 33 val=2;
jujuonthebeat 0:5755bf39c144 34 }
jujuonthebeat 0:5755bf39c144 35 if(digicode.read()==256){
jujuonthebeat 0:5755bf39c144 36 val=-2;
jujuonthebeat 0:5755bf39c144 37 }
jujuonthebeat 0:5755bf39c144 38 if(digicode.read()==512){
jujuonthebeat 0:5755bf39c144 39 val=9;
jujuonthebeat 0:5755bf39c144 40 }
jujuonthebeat 0:5755bf39c144 41 if(digicode.read()==1024){
jujuonthebeat 0:5755bf39c144 42 val=6;
jujuonthebeat 0:5755bf39c144 43 }
jujuonthebeat 0:5755bf39c144 44 if(digicode.read()==2048){
jujuonthebeat 0:5755bf39c144 45 val=3;
jujuonthebeat 0:5755bf39c144 46 }
jujuonthebeat 0:5755bf39c144 47 return val;
thomasstrcic 2:ae058dfdebac 48 }
thomasstrcic 2:ae058dfdebac 49
thomasstrcic 2:ae058dfdebac 50 void servo()
thomasstrcic 2:ae058dfdebac 51 {
thomasstrcic 2:ae058dfdebac 52 int c=0;
thomasstrcic 2:ae058dfdebac 53 t.start();
thomasstrcic 2:ae058dfdebac 54 t11.start();
thomasstrcic 2:ae058dfdebac 55 {
thomasstrcic 2:ae058dfdebac 56 while(c<1)
thomasstrcic 2:ae058dfdebac 57 {
thomasstrcic 2:ae058dfdebac 58 if (t11.read()>8)
thomasstrcic 2:ae058dfdebac 59 {
thomasstrcic 2:ae058dfdebac 60 t11.reset();
thomasstrcic 2:ae058dfdebac 61 c++;
thomasstrcic 2:ae058dfdebac 62 }
thomasstrcic 2:ae058dfdebac 63 if (t11.read()<4)
thomasstrcic 2:ae058dfdebac 64 {
thomasstrcic 2:ae058dfdebac 65 if(t.read()>0.02)
thomasstrcic 2:ae058dfdebac 66 { t.reset();}
thomasstrcic 2:ae058dfdebac 67 if (t.read()<0.0193)
thomasstrcic 2:ae058dfdebac 68 {
thomasstrcic 2:ae058dfdebac 69 s.write(1);
thomasstrcic 2:ae058dfdebac 70 }
thomasstrcic 2:ae058dfdebac 71 else
thomasstrcic 2:ae058dfdebac 72 {
thomasstrcic 2:ae058dfdebac 73 s.write(0);
thomasstrcic 2:ae058dfdebac 74 }
thomasstrcic 2:ae058dfdebac 75 }
thomasstrcic 2:ae058dfdebac 76 else
thomasstrcic 2:ae058dfdebac 77 {
thomasstrcic 2:ae058dfdebac 78 if(t.read()>0.02)
thomasstrcic 2:ae058dfdebac 79 { t.reset();}
thomasstrcic 2:ae058dfdebac 80 if (t.read()< 0.0175)
thomasstrcic 2:ae058dfdebac 81 {
thomasstrcic 2:ae058dfdebac 82 s.write(1);
thomasstrcic 2:ae058dfdebac 83 }
thomasstrcic 2:ae058dfdebac 84 else
thomasstrcic 2:ae058dfdebac 85 {
thomasstrcic 2:ae058dfdebac 86 s.write(0);
thomasstrcic 2:ae058dfdebac 87 }
thomasstrcic 2:ae058dfdebac 88 }
thomasstrcic 2:ae058dfdebac 89
thomasstrcic 2:ae058dfdebac 90
thomasstrcic 2:ae058dfdebac 91 }
thomasstrcic 2:ae058dfdebac 92 }
jujuonthebeat 0:5755bf39c144 93 }