Pages: [1]   Go Down
Author Topic: LEDs for Pin 10 and Pin 11  (Read 685 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
// 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);
}
}
Logged

Threadtech: Fashion Meets Technology

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18740
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 534
Posts: 26970
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18740
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Kailua-Kona, HI
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-grin

// 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);
}
}
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18740
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
void setup()
{
  for (byte i = 2; i <= 13; i++)
    pinMode(i, OUTPUT);
}
Logged


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

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

Threadtech: Fashion Meets Technology

Pages: [1]   Go Up
Jump to: