Arduino nano/atttiny85 to run 5 nano leds at same time for a project

Hello,

If anyone willing to advise me with some code. I am running an arduino nano/attiny85 to run 5 nano leds all in the same time. when running each code separately blinking, flickering they run fine but when combining all the code pieces together one works but not the others assuming it runs only the first command so do I need to add a while loop?

3 leds will be blinking

2 leds will be flickering

below is version 2 I patched up for what I need it to do just need to modify.

thank you

version 2
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''



int led_pin0 = 13; // blinking led
int led_pin1 = 10; // blinking led
int led_pin2 = 11; // blinking led 

 
int ledPin1 = 3; // flickering led,` 
int ledPin2 = 4; // flickering led, 


void setup() 
{

pinMode(led_pin0, OUTPUT); // blinking led
pinMode(led_pin1, OUTPUT); // blinking led
pinMode(led_pin2, OUTPUT); // blinking led


pinMode(ledPin1, OUTPUT); // flickering led 
pinMode(ledPin2, OUTPUT); // flickering led 


}

void loop()

{


digitalWrite(led_pin0,HIGH); // blinking led
  delay(1000); // blinking led
digitalWrite(led_pin0,LOW); // blinking led
  delay(1000); // blinking led
digitalWrite(led_pin1,HIGH); // blinking led
  delay(1000); // blinking led
digitalWrite(led_pin1,LOW); // blinking led
  delay(1000); // blinking led
digitalWrite(led_pin2,HIGH); // blinking led
  delay(1000); // blinking led
digitalWrite(led_pin2,LOW); // blinking led
  delay(1000); // blinking led


analogWrite(ledPin1, random(120)+130);  // flickering led  stock range (120-135)
analogWrite(ledPin2, random(100)+110);  // flickering led 
  delay(random(10));  // flickering time delay
}**


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

This is a simulation of an ATtiny85 running 12 LEDs. The code can be changed to Nano by changing pin numbers. More LEDs can be addressed by adding another shift register.

Landing gear x2, tail, port, starboard, passenger windows?

Use the sim to get your idea flying. I will start working on your specific points.

Why would you need a pin for leds that are constantly on? Just wire them to 5V (with series resistor, of course).

Please edit your post and put the code tags in correctly:

like this

Are you connecting all those LEDs directly to the nano pins?

Hi, @cpl_dan
Welcome to the forum.

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum
The link will show you how to place code into your post.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

correct, most leds will remain constant and can be wire directly to power so I will just modify code for the remaining function s of 3 blinking and 2 flickering to run at the same time. I modified the code a bit more as shown in the post I am guessing I need to run a while loop so while some of the leds and blinking the others will flicker as well...?

thanks

How about the power for all of those leds?

You could run them dim from the board which has a MAX pins draw of 200mA. Or you could use external power and transistors to power the leds.

I will be powering all the leds with several AAA batteries and on/off switch

decided to remove the 13 constant leds from the code and will wire them in a series circuit on their own to make it simpler and not stress the boards.

so will only have 2 flickering and 3 blinking leds to run all at the same time. code was updated to reflect this new change. was thinking of using a nano board but I can also program an Attiny85 which I have several as well as they are smaller.

1 Like

When working with dynamic leds, changes 40ms apart look to human eyes like motion. That's 25 FPS where 24 FPS is movie speed, images get blended. And to Arduino, 40ms can be a long time.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.