Attiny13 Led Project

I'm trying to make a Christmas themed LED project using Attiny13.
But I have problems.

The code works differently when I run the same code with 3 batteries and 1 battery.In the code I wrote, the LEDs must first blink sequentially and then all together. The code works correctly (First picture) with 3 batteries. But when I run the code with 1 battery (Second picture), only the 1st LED lights up and nothing else happens.

The same happens when I reduce the number of LEDs from 10 to 4. I was wondering if the battery was not strong enough.

Some people have made similar projects with more LEDs than this with 1 battery. What do you think is the problem? Hardware? Software?

#define LED_PIN_1 0
#define LED_PIN_2 1
#define LED_PIN_3 2
#define LED_PIN_4 3
#define LED_PIN_5 4


void setup() {
  pinMode(LED_PIN_1, OUTPUT);
  pinMode(LED_PIN_2, OUTPUT);
  pinMode(LED_PIN_3, OUTPUT);
  pinMode(LED_PIN_4, OUTPUT);
  pinMode(LED_PIN_5, OUTPUT);
}

void loop() {
  
  digitalWrite(LED_PIN_1, HIGH);
  digitalWrite(LED_PIN_2, LOW);
  digitalWrite(LED_PIN_3, LOW);
  digitalWrite(LED_PIN_4, LOW);
  digitalWrite(LED_PIN_5, LOW);  
  delay(1000);
    
  digitalWrite(LED_PIN_1, HIGH);
  digitalWrite(LED_PIN_2, HIGH);
  digitalWrite(LED_PIN_3, LOW);
  digitalWrite(LED_PIN_4, LOW);
  digitalWrite(LED_PIN_5, LOW);  
  delay(1000);
    
  digitalWrite(LED_PIN_1, HIGH);
  digitalWrite(LED_PIN_2, HIGH);
  digitalWrite(LED_PIN_3, HIGH);
  digitalWrite(LED_PIN_4, LOW);
  digitalWrite(LED_PIN_5, LOW);  
  delay(1000);
    
  digitalWrite(LED_PIN_1, HIGH);
  digitalWrite(LED_PIN_2, HIGH);
  digitalWrite(LED_PIN_3, HIGH);
  digitalWrite(LED_PIN_4, HIGH);
  digitalWrite(LED_PIN_5, LOW);  
  delay(1000);
    
  digitalWrite(LED_PIN_1, HIGH);
  digitalWrite(LED_PIN_2, HIGH);
  digitalWrite(LED_PIN_3, HIGH);
  digitalWrite(LED_PIN_4, HIGH);
  digitalWrite(LED_PIN_5, HIGH);  
  delay(1000);
    
  digitalWrite(LED_PIN_1, LOW);
  digitalWrite(LED_PIN_2, LOW);
  digitalWrite(LED_PIN_3, LOW);
  digitalWrite(LED_PIN_4, LOW);
  digitalWrite(LED_PIN_5, LOW);  
  delay(1000);  
    
  digitalWrite(LED_PIN_1, HIGH);
  digitalWrite(LED_PIN_2, HIGH);
  digitalWrite(LED_PIN_3, HIGH);
  digitalWrite(LED_PIN_4, HIGH);
  digitalWrite(LED_PIN_5, HIGH);  
  delay(1000);
    
  digitalWrite(LED_PIN_1, LOW);
  digitalWrite(LED_PIN_2, LOW);
  digitalWrite(LED_PIN_3, LOW);
  digitalWrite(LED_PIN_4, LOW);
  digitalWrite(LED_PIN_5, LOW);  
  delay(1000);
      
  digitalWrite(LED_PIN_1, HIGH);
  digitalWrite(LED_PIN_2, HIGH);
  digitalWrite(LED_PIN_3, HIGH);
  digitalWrite(LED_PIN_4, HIGH);
  digitalWrite(LED_PIN_5, HIGH);  
  delay(1000);
    
  digitalWrite(LED_PIN_1, LOW);
  digitalWrite(LED_PIN_2, LOW);
  digitalWrite(LED_PIN_3, LOW);
  digitalWrite(LED_PIN_4, LOW);
  digitalWrite(LED_PIN_5, LOW);  
  delay(1000);
    
}

CR2032 batteries are for very low current and besides you are not using current limiting resistors at all. I suggest you try a bigger battery and/or add a current limiting resistor to each LED.

Yes, those batteries can't supply enough current.

Also you will want to a 100 to 330 ohm resistor on each of the green wires leaving the ATiny13.

The forward voltage of a led is lower if the wavelength of the emitted color is larger. So let me guess that it is indeed the red led that is still turning on with one battery.

An infrared led could even do with less voltage, but only the camera in your smartphone can see that.

So up the voltage a bit and add resistors.

In this example project, there is no resistor included in all 8 LEDs. One 3V battery powered 16 LEDs. How does this battery have enough power?

You can access the project from this link.

No resistor was used in this project. How does 1 battery power 16 LEDs?

Could you review

> this project

? No resistor used here? But the LEDs work.

She is using the CR1225 battery, and a 68 Ohm resistor is used for the yellow leds that are constant on.

a CR1225 battery with a 50 mAh, a standard discharge current of 0.1-0.2 mA, a maximum continuous discharge current of 1 mA, and a pulse current of 5 mA.

So the overall current is so much out of spec for the coincell that the internal resistance of the coin may provide a built in protection. It just can't deliver enough to make things go wrong. The forward voltage of the leds may protect the AT13 from a brown-out situation. Provided that the brown out detection fuses are set right.

So, while ignoring normal practices for electronics design, this may actually work for a couple of minutes.

1 Like

I see. Thank you.

In the circuit I made, there will be attiny13, 8 SMD LEDs and 330ohm resistors. If I use a CR2032 battery, how many minutes or hours will the LEDs turn on?

The CR2032 seems to have 210mAH capacity. It's a 3 Volt coin.

let's assume your led has 2 Volt forward voltage, so (3 - 2 =) 1 volt needs to drop over the 330 Ohm resistor. That will result in 1 Volt / 330 Ohm = 3 milliAmpere per led.

8 leds will consume 8 x 3 = 24 milliAmpere

210mAH / 24 mA = 8.75 Hours (for just burning leds)

The T13 will consume power and if you PWM the leds, they will consume less power.
If your leds have higher forward voltage the consumption may be less.

No, I can't see the project. I guess they use resistors after all and maybe the program drives the LEDs through some sort of multiplexing i.e. not all LEDs light up at the same time, but very quickly line up in sequence. If done fast enough the human eye will not see the flashing and there may even be a small pause during which all the LEDs are off and maybe there is an auxiliary capacitor. The capacity of the battery also depends on the current used. The higher this current is, the lower the battery capacity is than stated.

From the data sheet of @hmeijdam .

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