3.7 V 450mAh capable of running 8 leds?

Question #1: Will this battery power all this?

Question#2: Will switching from an UNO pin layout to a Pro Mini work succesfully as shown below? If it won't work, is there anyway it could?

Question #3: Please have a look at this code and tell me if I'm being ridiculous and it will never work.

I just want some leds fading nicely in and out for my ufo (as seen in the background of pic#2) . This has been a lot of work for a ufo model :smiley: but now Im must finish because I spent a ton of money on this $8 model trying to make it light up and Im gonna look real stupid if I cant figure it out. Nothing new, just saying.

If you limit the current at ~15-20mA per LED you'll be ok with a total under 160mA

regarding the fading, you can use hardware PWM only for 6 channels. For more you need to program it in loop(). Not as easy as analogWrite() but possible.

I presume you are using a LiPo battery since you say 3.7v. It probably says on the battery how much current it can provide. I have some 240mAh cells that are rated 20C which means they can produce 20 * 240 milliamps or 4800 milliamps. Not for very long of course. And I would not like to use them at the maximum rate.

You should have no problem powering everything from your 450mAh cell - for a short period of time. How long depends on the total current that you draw.

LiPos do not like being discharged to a too-low voltage so you may want to arrange for the Arduino to monitor the voltage and shut things down at a safe level.

I would expect the Mini to waste less energy than an Uno.

...R

Yeah I don't get what I'm doing wrong. The ProMini lights up but none of the leds do.

I'm using a sketch for the uno. I know I was trying to take the easy way out, but I thought at least one of them would light up.

Now I think I have it wired wrong, but I don't know how I possibly could. I did not write this sketch. I've never written anything for Arduino.

int ledPins[] = {2,3,4,5,6,7,8,9};

void setup()
{
 int index;
for(index = 0; index <= 7; index++)
 {
   pinMode(ledPins[index],OUTPUT);
   // ledPins[index] is replaced by the value in the array.
   // For example, ledPins[0] is 2
 }
}


void loop()
{
 // This loop() calls functions that we've written further below.
 // We've disabled some of these by commenting them out (putting
 // "//" in front of them). To try different LED displays, remove
 // the "//" in front of the ones you'd like to run, and add "//"
 // in front of those you don't to comment out (and disable) those
 // lines.

 oneAfterAnotherNoLoop();  // Light up all the LEDs in turn

 //oneAfterAnotherLoop();  // Same as oneAfterAnotherNoLoop,
                           // but with much less typing

 //oneOnAtATime();         // Turn on one LED at a time,
                           // scrolling down the line

 //pingPong();             // Light the LEDs middle to the edges

 //marquee();              // Chase lights like you see on signs

 //randomLED();            // Blink LEDs randomly
}


/*
oneAfterAnotherNoLoop()

This function will light one LED, delay for delayTime, then light
the next LED, and repeat until all the LEDs are on. It will then
turn them off in the reverse order.

This function does NOT use a for() loop. We've done it the hard way
to show you how much easier life can be when you use for() loops.
Take a look at oneAfterAnotherLoop() further down, which does
exactly the same thing with much less typing.
*/

void oneAfterAnotherNoLoop()
{
 int delayTime = 100; // time (milliseconds) to pause between LEDs
                      // make this smaller for faster switching

 // turn all the LEDs on:

 digitalWrite(ledPins[0], HIGH); 
 delay(delayTime);                
 digitalWrite(ledPins[1], HIGH); 
 delay(delayTime);                
 delay(delayTime);               
 digitalWrite(ledPins[3], HIGH); 
 delay(delayTime);                
 digitalWrite(ledPins[4], HIGH):
 delay(delayTime);                
 digitalWrite(ledPins[5], HIGH); 
 delay(delayTime);                
 digitalWrite(ledPins[6], HIGH); 
 delay(delayTime);              
 digitalWrite(ledPins[7], HIGH);  
 delay(delayTime);                

 // turn all the LEDs off:

 digitalWrite(ledPins[7], LOW);   //Turn off LED #7 (pin 9)
 delay(delayTime);                //wait delayTime milliseconds
 digitalWrite(ledPins[6], LOW);   //Turn off LED #6 (pin 8)
 delay(delayTime);                //wait delayTime milliseconds
 digitalWrite(ledPins[5], LOW);   //Turn off LED #5 (pin 7)
 delay(delayTime);                //wait delayTime milliseconds
 digitalWrite(ledPins[4], LOW);   //Turn off LED #4 (pin 6)
 delay(delayTime);                //wait delayTime milliseconds
 digitalWrite(ledPins[3], LOW);   //Turn off LED #3 (pin 5)
 delay(delayTime);                //wait delayTime milliseconds
 digitalWrite(ledPins[2], LOW);   //Turn off LED #2 (pin 4)
 delay(delayTime);                //wait delayTime milliseconds
 digitalWrite(ledPins[1], LOW);   //Turn off LED #1 (pin 3)
 delay(delayTime);                //wait delayTime milliseconds
 digitalWrite(ledPins[0], LOW);   //Turn off LED #0 (pin 2)
 delay(delayTime);                //wait delayTime milliseconds  
}


/*
oneAfterAnotherLoop()

This function does exactly the same thing as oneAfterAnotherNoLoop(),
but it takes advantage of for() loops and the array to do it with
much less typing.
*/

void oneAfterAnotherLoop()
{
 int index;
 int delayTime = 100; // 
                     
 
 for(index = 0; index <= 7; index++)
 {
   digitalWrite(ledPins[index], HIGH);
   delay(delayTime);                
 }                                  



 for(index = 7; index >= 0; index--)
 {
   digitalWrite(ledPins[index], LOW);
   delay(delayTime);
 }               
}


/*
oneOnAtATime()

This function will step through the LEDs,
lighting only one at at time.
*/

void oneOnAtATime()
{
 int index;
 int delayTime = 100; // milliseconds to pause between LEDs
                      // make this smaller for faster switching

 // step through the LEDs, from 0 to 7

 for(index = 0; index <= 7; index++)
 {
   digitalWrite(ledPins[index], HIGH);  // turn LED on
   delay(delayTime);                    // pause to slow down
   digitalWrite(ledPins[index], LOW);   // turn LED off
 }
}


/*
pingPong()

This function will step through the LEDs,
lighting one at at time in both directions.
*/

void pingPong()
{
 int index;
 int delayTime = 100; // milliseconds to pause between LEDs
                      // make this smaller for faster switching

 // step through the LEDs, from 0 to 7

 for(index = 0; index <= 7; index++)
 {
   digitalWrite(ledPins[index], HIGH);  // turn LED on
   delay(delayTime);                    // pause to slow down
   digitalWrite(ledPins[index], LOW);   // turn LED off
 }

 // step through the LEDs, from 7 to 0

 for(index = 7; index >= 0; index--)
 {
   digitalWrite(ledPins[index], HIGH);  // turn LED on
   delay(delayTime);                    // pause to slow down
   digitalWrite(ledPins[index], LOW);   // turn LED off
 }
}


/*
marquee()

This function will mimic "chase lights" like those around signs.
*/

void marquee()
{
 int index;
 int delayTime = 200; // milliseconds to pause between LEDs
                      // Make this smaller for faster switching

 // Step through the first four LEDs
 // (We'll light up one in the lower 4 and one in the upper 4)

 for(index = 0; index <= 3; index++) // Step from 0 to 3
 {
   digitalWrite(ledPins[index], HIGH);    // Turn a LED on
   digitalWrite(ledPins[index+4], HIGH);  // Skip four, and turn that LED on
   delay(delayTime);                      // Pause to slow down the sequence
   digitalWrite(ledPins[index], LOW);     // Turn the LED off
   digitalWrite(ledPins[index+4], LOW);   // Skip four, and turn that LED off
 }
}


/*
randomLED()

This function will turn on random LEDs. Can you modify it so it
also lights them for random times?
*/

void randomLED()
{
 int index;
 int delayTime;

 

 index = random(8);    // pick a random number between 0 and 7
 delayTime = 100;

 digitalWrite(ledPins[index], HIGH);  // turn LED on
 delay(delayTime);                    // pause to slow down
 digitalWrite(ledPins[index], LOW);   // turn LED off
}

Code To Note

But before you wrote that, you wrote a simple 15 line test program to light the LEDs in sequence, right?

Did that sketch work?

Also, if you've got eight things, a for loop is more simply writtenfor (int i = 0; i < 8; i++), rather than mucking about with seven and a "<=".

const byte ledPins[] = {2,3,4,5,6,7,8,9};
const byte nLEDs = sizeof (ledPins) / sizeof (ledPins [0]);

(please remember to use code tags when posting code)

TheRealVictor:
Yeah I don't get what I'm doing wrong. The ProMini lights up but none of the leds do.

I'm using a sketch for the uno. I know I was trying to take the easy way out, but I thought at least one of them would light up.

Now I think I have it wired wrong, but I don't know how I possibly could.

First thing, go back to Reply #3 and edit it to put your code between code tags (the </> button)

so it looks like this

and is easy to copy to a text editor.

LEDs only pass power in one direction so it could be they are all wired backwards.

Make a pencil drawing showing how everything is connected and post a photo of the drawing. In the course of making the drawing you may find a wiring error.

...R

Maybe the voltage is just to low (for 16MHz or the LEDs)?

It's a Pro Mini (I did not read Pro Mini 3.3V anywhere) powered by a LiPo connected to what?

What is the voltage across the LEDs?

My vote is that the ground wire isn't making contact...

AWOL:
But before you wrote that, you wrote a simple 15 line test program to light the LEDs in sequence, right?

Did that sketch work?

Also, if you've got eight things, a for loop is more simply written

for (int i = 0; i < 8; i++)

, rather than mucking about with seven and a "<=".

const byte ledPins[] = {2,3,4,5,6,7,8,9};

const byte nLEDs = sizeof (ledPins) / sizeof (ledPins [0]);




(please remember to use code tags when posting code)

I wouldn't know how to write a 15 line test program for the leds. I thought that if I matched pins from the Uno to the Pro-Mini, It would work. I hate to ask but if it;s only 15 lines, do you have the time to help, or know o fa link that explains it?

Robin2:
First thing, go back to Reply #3 and edit it to put your code between code tags (the </> button)

so it looks like this

and is easy to copy to a text editor.

LEDs only pass power in one direction so it could be they are all wired backwards.

Make a pencil drawing showing how everything is connected and post a photo of the drawing. In the course of making the drawing you may find a wiring error.

...R

I fixed the code tags. You know that fancy looking diagram up there of the Uno and ProMini? ? I made that instead of a pencil drawing. That's how its hooked up. I'll do it again.

Whandall:
Maybe the voltage is just to low (for 16MHz or the LEDs)?

It's a Pro Mini (I did not read Pro Mini 3.3V anywhere) powered by a LiPo connected to what?

What is the voltage across the LEDs?

It's connected to a charger shield that plugs into laptop. I'm not sure what the voltage across the leds is. I don't even know how to figure it out.

DrAzzy:
My vote is that the ground wire isn't making contact...

My leds are sliding around in the breadboard holes and trying to lay down instead of being perfectly straight up and down. I've been worried about the connections all along.

I really need to find just a sketch that will light up as many leds as a Pro-Mini possibly can. Maybe some blinking and fading. Im just building a model of a ufo. I would think that there would be thousands of these sketches. Where are they all?