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