An arduino related problem

Thread Starter

Redscarf

Joined Jan 28, 2015
19
I was wondering if anyone could help me, it seems as if when ever i set certain pin in the ide the action is done in the pin above it. Say for instance if i used a simple led blinking function and set the led to pin 12 set that as an output, the action would occur in pin 13 rather than 12 as i had set it to do so. I was wondering if anyone knows of a way to fix this?
 

djsfantasi

Joined Apr 11, 2010
5,579
What action are you performing on pin 12? Also, how did you connect the LED to the Arduino?

Can you post your sketch?

Also, pin 13 is connected to the onboard LED. Could that be causing some confusion?
 

BillB3857

Joined Feb 28, 2009
2,497
Make sure you start counting pins at ZERO. I/O ZERO is the first position so the 2nd position is I/O 1.
 

Thread Starter

Redscarf

Joined Jan 28, 2015
19
What action are you performing on pin 12? Also, how did you connect the LED to the Arduino?

Can you post your sketch?

Also, pin 13 is connected to the onboard LED. Could that be causing some confusion?
Here's an example

int ledPin = 12

void setup() {
pinMode(ledPin, OUTPUT);
}


void loop() {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
Now how the function is set up pin 12 which the Led is connected to should be the output, but instead it is pin 13 that becomes the output.
This is is the same for every pin for some reason, like if it were in 2 that I designated as the output, it would be pin 3 that would become the out put. If use pin 13 in the function, the external led won't even work because it would go to the nonexistent pin 13.
 

Twigg

Joined Jul 25, 2015
23
Can you include a picture of your board and any connections?

I would meter check the power and ground pins and see if they line up with the silkscreen labels or if it's only when you do something to a pin in the IDE that it gets mixed up.
 

bullzai

Joined Jan 19, 2015
42
The labels being out of alignment on the board or just misread/difficult to read sounds like a good possibility. The pins might also be different depending on the model.

Which Arduino do you have? I believe the IDE defaults to the Uno.

Maybe load a fresh copy of the IDE onto the same computer or a different one and retry the sketch.
 
Top