# If it isn't 1 thing it's 2 others

Anyone have any ideas why digital pin 5 reads LOW? Nothing is attached to pin 5.

``````  int  intSwitch[8] = {2, 3, 4, 5, 6, 7, 8, 11};
Serial.begin(9600);
for(int i = 0; i < 8; i++){
pinMode(intSwitch[i], INPUT_PULLUP);
}
for(int i = 0; i < 8; i++){
}
``````

Output: 1 1 1 1 0 1 1 1

You may have a bad pin 5.

Show us a image of the setup.

BTW
for(int i = 0; i < 8; i++){

• }*
Suggest you write it as:
for(int i = 0; i < 8; i++)
• {*
_
}_
Pin 5 or 6?
_
.*_

larryd:
BTW

``````for(int i = 0; i < 8; i++){
``````

}

``````

Suggest you write it as:

``````

for(int i = 0; i < 8; i++)
{
}

Just a matter of style. I prefer the former (but with a space before the ‘{’).

Is it the same unit that you used with this post?

You might have blown the pin back then.

Good memory.

I never actually plugged in any switches. It was just concept at that time and now I'm developing code to that, but again, nothing is attached.

The Arduino Uno is plugged into my desktop PC via USB cord. Was just developing code to read 8 switches that WOULD BE connected to pins 2, 3, 4, 5, 6, 7, 8 and 11. When the code checked for a LOW value (where a future switch would be connected) in an IF() it showed up. But all the pins should have been HIGH. So I whipped up the above code to see what was going on... and voila!

So the best guess is that the UNO just dropped a pin? Terrific!

Is there a way to definitively verify the pin is dead?

BTW your suggestion about the brace is semantics. At 67 (I started coding in DOS, Fortran and assembler) we're lucky I even comment my code.

johnwasser:
Just a matter of style. I prefer the former (but with a space before the ‘{’).

Yes, a matter of style.

I think it helps to expose any ugly ; if there is one.
for(int x = 0; x < 20; x++);{ <----<<<<

I prefer the later, as mentioned just a suggestion to the OP.

.

Is there a way to definitively verify the pin is dead?

Write code just operating on this pin.
Maybe see if it can be used as an output.

Pin 5 or pin 6?

.

The plot thickens...

I just changed the above code to

``````int  intSwitch[8] = {2, 3, 4, 6, 7, 8, 11, 12};
``````

and now pin 6 is returning 0!

So then I changed it to`int  intSwitch[8] = {2, 3, 4, 7, 8, 11, 12, 13};`
Same result. Whatever pin is assigned to the fourth element of intSwitch doesn't get set HIGH.

Now what?

int intSwitch[8] = {2, 3, 4, 5, 6, 7, 8, 11};

Output: 1 1 1 1 0 1 1 1

is less significant bit first ? is pin 4 or 6 that is trouble ?

have you en ethernet shield atached with your arduino.

also you could try put 5v directly to touble pin to see if it is a pullup problem

``````for(int i = 0; i < 8; i++){
Serial.print("Pin ");
Serial.print(intSwitch[i]);
}
``````

You see, you haven’t posted your whole sketch, only snippets. So I am not confident that this array is being initialized and not being altered by something else.

MavenScout:
The plot thickens...

I just changed the above code to

``````int  intSwitch[8] = {2, 3, 4, 6, 7, 8, 11, 12};
``````

and now pin 6 is returning 0!

So then I changed it to

``````int  intSwitch[8] = {2, 3, 4, 7, 8, 11, 12, 13};
``````

Same result. Whatever pin is assigned to the fourth element of intSwitch doesn't get set HIGH.

Now what?

I tested your code and got 11111111. What is your board sitting on?

Larryd, you’re right, I miscounted. It’s pin 6.

nitrof, It’s not binary, it’s just printing the HIGH/LOW of each pin. I don’t have anything connected to the Arduino but a USB cable. Just testing ideas at this point. The applying 5v to the pin is a good idea. I’ll try that tomorrow when my frustration level has subsided.

aarg, PRECISELY!!

MavenScout:
aarg, PRECISELY!!

Huh? I wasn't jesting... what is it resting on?

PaulMurrayCbr, You're code produces this: