signal from unused pins

Hi Guys,

I am very new to arduino and I am struggling with a simple thing. I am getting suspicious if my arduino board is broken or something. Anyway, I wrote a simple code, which is;

void setup() {

pinMode (11, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
}
void loop() {
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
delay(1000);

}

so I am expecting only #11 led to blink but #9 &10 are also on, I even added these lines in the loop;
digitalWrite(10, LOW);
digitalWrite(9, LOW);
but they still turn on. but if I want to blink #9 & 10 they do blink and the outputs work properly.
I deleted the lines that I declare #9 & 10 in the setup and they turned off only that way.
I cant understand the problem.
Can you help me with this please?
Thanks

kutalp:
I cant understand the problem.

you call pinMode on the pins, but you never put them into any known state.

set them high or low in setup

I tried it but still the same result, I put this;

void setup() {

pinMode (2, INPUT);
pinMode (6, INPUT);
pinMode (11, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
}
void loop() {
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
delay(1000);
}

leds are connected to those pins and they are on.

Do you have LEDs on 9 & 10 to show that they are 'on'?
If so, how do you have them hooked up? Pin to anode, cathode to GND, or pin to cathode, anode to 5V? With resistors, of course?

yes sure, I attached a picture, the led on the left is connected to #11 and it is blinking, the other ones are connected to #9 & 10 and they are constantly on.

when I write this;

void loop() {
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
delay(1000);
digitalWrite(10, HIGH);
delay(1000);
digitalWrite(10, LOW);
delay(1000);
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
}

it works properly and all three of them blinks in ordered.

Don't write that. Just begin with something simple. Write to pin 10 only. Forget the rest for now.

For one of your arduino programs..just write a high to pin 10.... then tell us whether the led light is on or off.

Then... in a different program.... write a low to pin 10.... then report on the led... lit up? Or not lit up?

The trick here is...... if you write a high to pin 10 ....and the result is led light OFF..... and if you write a low to pin 10 which results in the light turning ON ........... then this is the behaviour of the system. Once you know the behaviour.... you then know how to control this system.

actually that is kind of what I am doing, it is not working properly so I am stepping back each time and testing it.
the thing is when I declare an output in setup, it is HIGH as default. I tried putting digitalWrite(9, LOW) in the loop, but it didnt work out, it is still high, it turns the LED on.

on the example above, if I delete the lines that I declared #9 & 10 in the setup, then the LED doesnt turn on.

the strange thing is, when I want to blink them all, they all blink properly and the program runs flawless.
and another example;
when I write this;
void setup() {

pinMode (2, INPUT);
pinMode (6, INPUT);
pinMode (11, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
}
void loop() {
digitalWrite(10, HIGH);
delay(1000);
digitalWrite(10, LOW);
delay(1000);
}

it blinks # 10 but #9 & 11 is on constantly

same case on this;

void setup() {

pinMode (2, INPUT);
pinMode (6, INPUT);
pinMode (11, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
}
void loop() {
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
}

OMG I just wrote high for pin #9 and #10 and blinked #11 and they didnt turn on. it worked actually
thank you
but why???
it doesnt make sense, when I write high it should be on and when I write low it should be off isn't it???

kutalp:
OMG I just wrote high for pin #9 and #10 and blinked #11 and they didnt turn on. it worked actually
thank you
but why???
it doesnt make sense, when I write high it should be on and when I write low it should be off isn't it???

Have you read the labels on the pins that you connected to? Your breadboard(-) is connected to +3.3V and your (+) is connected to ground.

Let me guess, you found the polarity of the LEDs by trial and error plugging?

You have wired your LEDs to be ACTIVE LOW.

Follow the 5V pin on your Arduino. The white wire.
It goes to the LED, and then into one of the I/O pins.
You are using the I/O pins as the GND.

In other words, whenever your pins are LOW, the 5V can come through the LED+resistor and turn on.

Furthermore, your pin 11 which you think is working correctly is actually not. If you change the delays to be offset, like HIGH for 1000ms and LOW for 5000ms, you will notice the LED is actually OFF for 1 sec and ON for 5 sec.

kutalp:
actually that is kind of what I am doing, it is not working properly so I am stepping back each time and testing it.

Nope. Stop right there. Read post #10 again..... line by line. And follow the guide there. Line by line.

click here

Don't fall into the habit of not paying attention to details.

At the moment..... your system is configured in a particular way. It is like ...... I tell you to sit down, but you stand up ....... and I tell you to stand up, but you sit down. That's the way it is operating right now.

So basically, since I know your behaviour .... ie. you consistently do the opposite of what I tell you to do..... then I can easily make you sit down. All I have to say to you is 'stand up'..... and you'll sit down.

Delta_G:
The only difference is that in this example he is not doing what you told him to but is instead doing the opposite. In the OPs case the board is doing exactly what he told it to. It is only the OP's expectations that are wrong. He is expecting the LED, which is wired as active LOW, to light when he writes a HIGH to it. And that's wrong. HIGH should make it turn off, not on.

You are right Delta_G. Correct. He/she just needs to know the behaviour. Once the behaviour is known, then at least they can control the system in the way they want. For the OP's case ..... absolutely right. The system is doing what it is meant to do. Writing a high is supposed to turn off the LED light (and vice versa).

For cases where somebody doesn't understand the reason for something doing the opposite of what they believed it should do, then all is not lost if they at least understand that the system just does something opposite to what they 'believe' it should do.

kutalp:
it doesnt make sense, when I write high it should be on and when I write low it should be off isn't it???

WRONG! Wrong wrong wrong wrong wrong and multiple people have told you this multiple times.

HIGH means that the pin is driven to 5V. LOW means it is driven to 0V. That's it. What those voltages do depends entirely on the circuit the pins are connected to.

Your first mistake is that you have the power connections to the breadboard backwards. You have 5V going to the blue side and GND going to the red side. This is backwards from the normal convention, and has also been pointed out to you in a previous post.

Everything else follows from this "mistake". That's why it seems backwards.

A look at LEDs D3 and D8 in the image.

If Arduino pin 13 goes LOW, LED D3 will turn ON

If Arduino pin 8 goes High, LED D8 will turn ON

Do you see how both LOW and HIGH can make a LED go ON?

Thank you very much guys, I must have wired them the other way around. I am at work at the moment but when I get back home I will check again.

Appreciate...

It's not just that they're connected the wrong way around, they're connected to the wrong power rail. If you want them to be active HIGH, they must be connected to GND not +5V.