Go Down

Topic: Blink problem (Read 802 times) previous topic - next topic


Hi. newbie to Arduino I bought the ONE and lcd keypad shield.
Trying to make someting I have two leds (red and green) and for a stupid test I modified the blink example
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.

void setup() {               
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(9, OUTPUT);   
  pinMode(12, OUTPUT); 

void loop() {
  digitalWrite(9, HIGH);   // set the LED
  digitalWrite(12, LOW);
  delay(1000);              // wait for a second
  digitalWrite(9, LOW);    // set the LED off
    digitalWrite(12, HIGH);
  delay(1000);              // wait for a second
The problem is that leds blink all together...Where is the problem???? I also tryed to compile with an old software version but it is the same


How did you connect them?


Gnd is common with a resistor and one to pin 9 and other to pin 12.
I also notice that if i dont use one of the two led and tell the arduino to blink pin 13 and other pin, if i use only the led on the board the leds blinkright...if i connect the normal led on the pin 13 also , the two leds blink as one....


Gnd is common with a resistor and one to pin 9 and other to pin 12.

A picture is going to be necessary, because this description is not any where near adequate.

"Ground is common with a resistor" is nonsense. We expected that you connected one LED to pin 9 and the other end to pin 12. But, which leg of the LED is connected to the pin? Where is the other leg connected?
The art of getting good answers lies in asking good questions.


I have not an image at the moment

I'll try to explain better.

        pin 9 -------------------
                                     led green
                                     led red
       pin12 --------------------

I think is clear.
Thank you


(disclaimer: sw guy speaking here)

That way the current flowing through the resistor is different if one or both leds are on. And that's a Bad Thing (tm), as the v=ri across R will vary too. Is this correct ?


It should be like this:

pin 9 -----resistor--------  green LED -------- ground

pin12 -----resistor-------- red LED ------------ground

Be sure you have the LED anode (long pin) to the resistor, and the cathode (flat spot) to ground.


Go Up