Go Down

Topic: LEDs for Pin 10 and Pin 11 (Read 736 times) previous topic - next topic

colleenjmorgan

Hi all,

I must start by saying that I am very new to arduino.  I am using the Lilypad Arduino and am trying to get multiple LEDs to fade in and out. 

I have been pretty successful, however the LEDs attached to Pins 10 and 11 seem to mimic one another even if I try to program them to do different things, ie. fade in and out at different times.

Is this normal????

Ive written some code for LEDs attached to Pins 5,6,9,10 and 11 to fade in and then out all together, then to fade in and out one at a time. They all fade in and out together, however when it gets to fading them one at a time the LEDs on 10 and 11 don't do anything.

Any help will be really appreciated.

Here's my code:
Code: [Select]

// fading LEDs

int value = 0;

void setup()
{
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
}

void loop()
{
  for(value = 0; value <= 255; value+=5)     // fade LEDs in
  {
    analogWrite(5, value);
    analogWrite(6, value);
    analogWrite(9, value);
    analogWrite(10, value);
    analogWrite(11, value);
    delay(30);                               // take 30 mili seconds to fade in
  }
  delay(200);                                // leave the LEDs on for 200 milliseconds


  for(value = 255; value >=0; value-=5)      // fade LEDs out
{
  analogWrite(5, value);
  analogWrite(6, value);
  analogWrite(9, value);
  analogWrite(10, value);
  analogWrite(11, value);
  delay(30);                                // take 30 mili seconds to fade out
}
  delay(1000);                              // leave LEDs off for 1 second


  for(value = 0; value <= 255; value+=5)     // fade LED 5 in
  {
    analogWrite(5, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 5 out
{
  analogWrite(5, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 6 in
  {
    analogWrite(6, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 6 out
{
  analogWrite(6, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 9 in
  {
    analogWrite(9, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 9 out
{
  analogWrite(9, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 10 in
  {
    analogWrite(10, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 10 out
{
  analogWrite(10, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 11 in
  {
    analogWrite(11, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 11 out
{
  analogWrite(11, value);
  delay(30);
}
}

Threadtech: Fashion Meets Technology

Nick Gammon

I just tried your code with 5 LEDs and it worked perfectly (on a Uno - I don't have a Lilypad). I suspect a wiring problem.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

CrossRoads

That's a good one!
I don't see anything in the code, and if they work as a group it seems to indicate the hardware is wired correct & works.

How about some more details -  IDE version? Schematic?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Nick Gammon

My only complaint about the code is that the LEDs seem to go on faster than they go off. I can't quite explain that. Is it our logarithmic perception of light? But why would that be faster in the on direction than the off direction? And LEDs don't exactly have filaments that have to cool down.

Quote

I don't see anything in the code, and if they work as a group it seems to indicate the hardware is wired correct & works.


Well, no. As a group, 10 and 11 might be connected together, and as a group come on together.

Quote

They all fade in and out together, however when it gets to fading them one at a time the LEDs on 10 and 11 don't do anything.


So if 10 and 11 are connected to 5 (say) then the group will appear to work. But of course in this case when doing them individually when 5 did its stuff you would see 10 and 11 light up as well.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

islandbehr

I was wondering how I can work a pseudorandom long integer into sketch using:
long randnum = random(0, 100); //a number between 0 and 99

Thanks  :D

// fading LEDs

int value = 0;

void setup()
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop()
{
  for(value = 0; value <= 255; value+=5)     // fade LEDs in
  {
    analogWrite(2, value);
    analogWrite(3, value);
    analogWrite(4, value);
    analogWrite(5, value);
    analogWrite(6, value);
    analogWrite(7, value);
    analogWrite(8, value);
    analogWrite(9, value);
    analogWrite(10, value);
    analogWrite(11, value);
    analogWrite(12, value);
    analogWrite(13, value);
    delay(30);                               // take 30 mili seconds to fade in
  }
  delay(200);                                // leave the LEDs on for 200 milliseconds


  for(value = 255; value >=0; value-=5)      // fade LEDs out
{
  analogWrite(2, value);
  analogWrite(3, value);
  analogWrite(4, value);
  analogWrite(5, value);
  analogWrite(6, value);
  analogWrite(7, value);
  analogWrite(8, value);
  analogWrite(9, value);
  analogWrite(10, value);
  analogWrite(11, value);
  analogWrite(12, value);
  analogWrite(13, value);
  delay(30);                                // take 30 mili seconds to fade out
}
  delay(1000);                              // leave LEDs off for 1 second


  for(value = 0; value <= 255; value+=5)     // fade LED 5 in
  {
    analogWrite(5, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 5 out
{
  analogWrite(5, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 2 in
  {
    analogWrite(2, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 2 out
{
  analogWrite(2, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 3 in
  {
    analogWrite(3, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 3 out
{
  analogWrite(3, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 4 in
  {
    analogWrite(4, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 4 out
{
  analogWrite(4, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 6 in
  {
    analogWrite(6, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 6 out
{
  analogWrite(6, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 7 in
  {
    analogWrite(7, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 7 out
{
  analogWrite(7, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 8 in
  {
    analogWrite(8, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 8 out
{
  analogWrite(8, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 9 in
  {
    analogWrite(9, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 9 out
{
  analogWrite(9, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 10 in
  {
    analogWrite(10, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 10 out
{
  analogWrite(10, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 12 in
  {
    analogWrite(12, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 12 out
{
  analogWrite(12, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 13 in
  {
    analogWrite(13, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 13 out
{
  analogWrite(13, value);
  delay(30);
}


  for(value = 0; value <= 255; value+=5)     // fade LED 11 in
  {
    analogWrite(11, value);
    delay(30);
  }
   for(value = 255; value >=0; value-=5)      // fade LED 11 out
{
  analogWrite(11, value);
  delay(30);
}
}

Nick Gammon

Please use the "code" tag when posting. Also save yourself some trouble by using loops, eg.

Code: [Select]
void setup()
{
  for (byte i = 2; i <= 13; i++)
    pinMode(i, OUTPUT);
}
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

colleenjmorgan

Thanks everyone for your replies.

Turns out sometimes you just need to have a good close look at your hardware.  There appears to be a small blob of solder that is joining pins 10 and 11.

I haven't seen this on any other lilypad.  It must just be a fault in mind!
Threadtech: Fashion Meets Technology

Go Up