Création électro pour ClickClick Graphique ; destination le musée napoléonien à Genappe


//Debounce ? http://www.arduino.cc/en/Tutorial/Debounce
//residence 10k + condensateur 10nf

#include

//Initialize the Mux Shield
MuxShield muxShield;

boolean digitalA[16], digitalB[16];
boolean pushed = 1;
int i,j;
//btn activé le + elevé
int A = 0, B = 0, LedV = 15, LedR = 13;

void setup()
{
muxShield.setMode(1, DIGITAL_IN_PULLUP); //set I/O 1 and 2 as digital in with pullup
muxShield.setMode(2, DIGITAL_IN_PULLUP);
muxShield.setMode(3, DIGITAL_OUT);//set I/O 3 as digital output

Serial.begin(9600);
muxShield.digitalWriteMS(3, LedV, LOW); //verteOff
muxShield.digitalWriteMS(3, LedR, LOW) ; //rougeOFF
}

void loop()
{

//lecture de toutes les In
for (i = 0; i < 10; i++) { digitalA[i] = muxShield.digitalReadMS(1, i); if (digitalA[i] == pushed) { A = i + 1; //enregistrement du n du btn appuyé entre 1 et 16 } }; for (i = 0; i < 12; i++) { digitalB[i] = muxShield.digitalReadMS(2, i); if (digitalB[i] == pushed) { B = i + 1; //enregistrement du n du btn appuyé entre 1 et 16 } }; Serial.print(" A="); Serial.print(A); Serial.print(" B="); Serial.println(B); // A et B donne un signal if (A > 0 && B > 0)
{
//A != B alors rouge
if (A != B)
{
if ( A == 8 && B == 11)
{
LEDverte();
}

else if (A == 4 && B == 12) {
LEDverte();
}
else {
LEDrouge ();
};
} else {
LEDverte ();

};
};
//A = B alors vert

A = 0; B = 0;
muxShield.digitalWriteMS(3, LedV, LOW); //verteOff
muxShield.digitalWriteMS(3, LedR, LOW) ; //rougeOFF

}

void LEDverte () {
Serial.print("verte"); Serial.print(" -- A="); Serial.print(A); Serial.print(" & B="); Serial.println(B);
muxShield.digitalWriteMS(3, LedR, LOW) ;
for (j = 0; j < 5; j++) { muxShield.digitalWriteMS(3, LedV, HIGH); //verteOn delay(50); muxShield.digitalWriteMS(3, LedV, LOW); delay(50); }; muxShield.digitalWriteMS(3, LedV, HIGH); delay(2000); muxShield.digitalWriteMS(3, LedV, LOW); }; void LEDrouge () { Serial.print("rouge"); Serial.print(" -- A="); Serial.print(A); Serial.print(" & B="); Serial.println(B); muxShield.digitalWriteMS(3, LedV, LOW) ; for (j = 0; j < 5; j++) { muxShield.digitalWriteMS(3, LedR, HIGH); //verteOn delay(50); muxShield.digitalWriteMS(3, LedR, LOW); delay(50);}; muxShield.digitalWriteMS(3, LedR, HIGH); delay(2000); muxShield.digitalWriteMS(3, LedR, LOW); };