Arduino Uno test

I wanted to do a quick check if all the digital pins on my Arduino Uno were still working.  The Arduino Uno has 14 digital pins, these can all be set as input or output. So I needed a sketch with 14 times the same statement to declare the pins as output and to write them high. That’s a lot of typing 🙂 But I found out that there is an easier way. Store all the pin numbers in an array…

So I came up with the following simple sketch 🙂

/*
  http://www.bajdi.com
  Set all digital pins as outputs and write them high.
 */
int outputPins[] = {
  0,1,2,3,4,5,6,7,8,9,10,11,12,13};

void setup() {
  for(int index = 0; index < 14; index++)
  {
    pinMode(outputPins[index], OUTPUT);
  }
}

void loop() {
  for(int index = 0; index < 14; index++)
  {
    digitalWrite(outputPins[index], HIGH);
  }
}

Leave a Reply

*