An arduino related problem

Discussion in 'Embedded Systems and Microcontrollers' started by Redscarf, Nov 20, 2015.

  1. Redscarf

    Thread Starter New Member

    Jan 28, 2015
    19
    0
    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?
     
  2. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,815
    835
    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?
     
  3. BillB3857

    Senior Member

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

    Thread Starter New Member

    Jan 28, 2015
    19
    0
    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.
     
  5. Twigg

    New Member

    Jul 25, 2015
    22
    1
    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.
     
    djsfantasi likes this.
  6. bullzai

    New Member

    Jan 19, 2015
    1
    0
    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.
     
Loading...