EDIT:
Problem solved the arduino board was bad, I swapped it out with a different one and it fixed the problem.
I am extremely new to programming.
The problem I have is that I have a working 8 bit binary counter to led display however when I add in the code to monitor the state of digital pin 13 to set the outputs to low instead of counting it doesn't, it just ignores the pin and starts counting
int ledPin[] = {2, 3, 4, 5, 6, 7, 8, 9}; //define digital output pins
int val = 0; //define digital input state of high or low
void setup()
{
pinMode (13, INPUT_PULLUP); // set digital pin 13 to pullup high
// setup output pins for display
for (int i = 0; i < 8; i++)
{
pinMode(ledPin[i], OUTPUT);
}
}
void loop()
{
val = digitalRead(13); // read the state of pin 13
if (val == HIGH)
{
for (int i = 0; i < 8; i++)
{
digitalWrite(ledPin[i], LOW); // set digital outs to low
}
}
else
{
for (byte counter = 0; counter <= 256; counter++)
{
displayBinary(counter);
delay(100);
}
}
}
void displayBinary(byte numToShow)
{
for (int i =0;i<8;i++)
{
if (bitRead(numToShow, i)==1)
{
digitalWrite(ledPin[i], HIGH);
}
else
{
digitalWrite(ledPin[i], LOW);
}
}
}