/** * Code de test pour les entrées d'une carte Arduino UNO. */ /* Constantes pour les boutons */ const byte BUTTONS_PIN[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, A0 }; const byte BUTTONS_COUNT = 12; /* Constantes pour le reste du montage */ const byte STATUS_LED_PIN = 13; /** Fonction setup() */ void setup() { /* Place les boutons en entrées avec pull-up */ for (byte i = 0; i < BUTTONS_COUNT; ++i) { pinMode(BUTTONS_PIN[i], INPUT_PULLUP); } /* Place la LED de statut en sortie */ pinMode(STATUS_LED_PIN, OUTPUT); digitalWrite(STATUS_LED_PIN, LOW); /* Initialise le port série */ Serial.begin(9600); } /** Fonction loop() */ void loop() { /* Test chaque bouton */ for (byte i = 0; i < BUTTONS_COUNT; ++i) { /* Bouton actif ? */ if (digitalRead(BUTTONS_PIN[i]) == LOW) { Serial.write('X'); } else { Serial.write(' '); } } Serial.println(); digitalWrite(STATUS_LED_PIN, LOW); delay(500); digitalWrite(STATUS_LED_PIN, HIGH); delay(500);