int firstSensor = 22; int firstState = 0; int secondSensor = 23; int secondState = 0; int thirdSensor = 24; int thirdState = 0; int fourthSensor = 25; int fourthState = 0; int fifthSensor = 26; int fifthState = 0; int sixthSensor = 27; int sixthState = 0; int seventhSensor = 28; int seventhState = 0; int eighthSensor = 29; int eighthState = 0; int tab[8]; void setup() { // Cette setup permet de définir la vitesse de communication des deux ports série, soit un 9600 BAUD. // Elle permet également de mettre tous les pins utilisés par le programme en sortie pinMode(firstSensor, INPUT); pinMode(secondSensor, INPUT); pinMode(thirdSensor, INPUT); pinMode(fourthSensor, INPUT); pinMode(fifthSensor, INPUT); pinMode(sixthSensor, INPUT); pinMode(seventhSensor, INPUT); pinMode(eighthSensor, INPUT); Serial.begin(9600); Serial1.begin(9600); } void loop() { //Cette boucle lit les valeurs des 8 capteurs, les met dans un tableau puis envoie chaque case du tableau par la liaison série. int envoi = 0; firstState = digitalRead(firstSensor); secondState = digitalRead(secondSensor); thirdState = digitalRead(thirdSensor); fourthState = digitalRead(fourthSensor); fifthState = digitalRead(fifthSensor); sixthState = digitalRead(sixthSensor); seventhState = digitalRead(seventhSensor); eighthState = digitalRead(eighthSensor); if((firstState != tab[0]) || (secondState != tab[1]) || (thirdState != tab[2]) || (fourthState != tab[3]) || (fifthState != tab[4]) || (sixthState != tab[5]) || (seventhState != tab[6]) || (eighthState != tab[7])){ tab[0]=firstState; tab[1]=secondState; tab[2]=thirdState; tab[3]=fourthState; tab[4]=fifthState; tab[5]=sixthState; tab[6]=seventhState; tab[7]=eighthState; if(firstState==1) { envoi=envoi+1; } if(secondState==1) { envoi=envoi+10; } if(thirdState==1) { envoi=envoi+100; } if(fourthState==1) { envoi=envoi+1000; } if(fifthState==1) { envoi=envoi+10000; } if(sixthState==1) { envoi=envoi+100000; } if(seventhState==1) { envoi=envoi+1000000; } if(eighthState==1) { envoi=envoi+10000000; } Serial1.print((char)envoi); Serial.print(envoi); } }