Pages: [1]   Go Down
Author Topic: Blink problem  (Read 358 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
/*
  Blink
  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
Logged

Netherlands
Offline Offline
Full Member
***
Karma: 0
Posts: 123
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How did you connect them?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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....
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46026
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have not an image at the moment

I'll try to explain better.

        pin 9 -------------------
                                     led green
       gnd------resistor--------
                                     led red
       pin12 --------------------


I think is clear.
Thank you



Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(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 ?
Logged

Canada
Offline Offline
Sr. Member
****
Karma: 0
Posts: 318
Sometimes teaching, always learning,
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

                                   
Logged


Pages: [1]   Go Up
Jump to: