I have designed and coded a circuit for the ATTiny85 that Randomly blinks at random durations 1 of 4 LEDs. I am only using 2 of the 6 pins available on the chip by using the Tri state function of the GPIO pins.(in plain English, I made the two pins do 3 different things, Sink, source, and Open (or HI-Z))

I programmed everything with the MIT method using an Uno as an ICSP. The relevant part of this project is the code. I'm not sure if anyone has posted anything similar but I pretty much did this without much reference to anything else.

/*Code by Nick Tracy 2013 May contain code parts from other programs, all credit goes to those who helped. Designed around the ATTiny85 @ 8 Mhz with internal oscillator, accuracy is not important here and is actually beneficial. This code uses a random number generator to simulate a twinkling effect on 4 different outputs. Used in a decoration for the holidays, can be used for just about anything really. it uses 4 LEDs connected to 2 pins (3 and 4 for ATTiny85) that are Tri-stated to provide a HIGH, LOW, and High Impedance output. the LEDs are connected in a sink/source set up on each pin. when the pin mode is changed to the third state the LEDs on that pin are off. */

//Use Define so that not a lot of memory is wasted.#define LED1 3#define LED2 4//long for random number variableslong rand1;long rand2;long rand3;

//Switch case for selecting the appropriate LED //Fires one Random LED at a time each loop at a random duration On and Off. switch (rand1){ case 1:

pinMode(LED1, OUTPUT); //set pin mode to output pinMode(LED2, INPUT_PULLUP); //makes sure other output is off digitalWrite(LED1, HIGH); //turn on led number 1 of 4 delay(rand2); //delay for On duration pinMode(LED1, INPUT_PULLUP); //turn off the output delay(rand3); //delay before next cycle break;

case 2:

pinMode(LED1, OUTPUT); //set pin mode to output pinMode(LED2, INPUT_PULLUP); //makes sure other output is off digitalWrite(LED1, LOW); //turn on led number 2 of 4 delay(rand2); //delay for On duration pinMode(LED1, INPUT_PULLUP); //turn off the output delay(rand3); //delay before next cycle break;

case 3:

pinMode(LED2, OUTPUT); //set pin mode to output pinMode(LED1, INPUT_PULLUP); //makes sure other output is off digitalWrite(LED2, HIGH); //turn on led number 3 of 4 delay(rand2); //delay for On duration pinMode(LED2, INPUT_PULLUP); //turn off the output delay(rand3); //delay before next cycle break;

case 4:

pinMode(LED2, OUTPUT); //set pin mode to output pinMode(LED1, INPUT_PULLUP); //makes sure other output is off digitalWrite(LED2, LOW); //turn on led number 4 of 4 delay(rand2); //delay for On duration pinMode(LED2, INPUT_PULLUP); //turn off the output delay(rand3); //delay before next cycle break;

default: //If no LED is selected, turn off all LEDs for a random amount of time. pinMode(LED1, INPUT_PULLUP); pinMode(LED2, INPUT_PULLUP); delay(rand2); }}

EDIT: The LEDs I used were White with a 3.2v drop and 20ma draw. but with different resistor values you can use any LED so long as you choose the correct current limiting resistor for your LED.

My only issue here is that two of the LEDs are dimly lit in the HI-Z state due to the internal pull up resistors. there is just enough current to light the LEDs I'm using. if anyone has a recommendation for that let me know.

Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. XD

This method could be used to expand the amount of leds. Just duplicate this to each pin and change the code accordingly by adding new case switch statements and changing the max number for the random function.

Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. XD

You can easily view the image by right clicking it and clicking "view image" it will open the full image in a new window. I won't change the resolution of the image because it may lower the quality, not my fault the arduino forum can't properly handle image attachments like every other forum software out there.

Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. XD

1. I assumed you are wiring the LEDs the way you are in fact wiring them. If the forward voltage was close to 2.5V it could explain the symptom. In your first post you failed to mention the fact that you are using white / forward voltage = 3.2V LEDs. By asking for the schematic I can validate my assumption and confirm the forward voltage is high enough for the circuit to work.

2. Anyone new to Arduinos / electronics who wants to build a similar device is going to have trouble without a schematic. In addition, they would be rather disappointed if they had used red LEDs instead of white. By providing details you are helping future adventurers.

My only issue here is that two of the LEDs are dimly lit in the HI-Z state due to the internal pull up resistors. there is just enough current to light the LEDs I'm using. if anyone has a recommendation for that let me know.

The reason I used the internal pullup resistors is because i had read that with any CMOS chip, if you leave an input pin floating in this circuit, you could damage the chip. is this not true for the AVR chips?

1. I assumed you are wiring the LEDs the way you are in fact wiring them. If the forward voltage was close to 2.5V it could explain the symptom. In your first post you failed to mention the fact that you are using white / forward voltage = 3.2V LEDs. By asking for the schematic I can validate my assumption and confirm the forward voltage is high enough for the circuit to work.

I tried this with other LEDs besides red and i can confirm that it will work with most leds, for the red all i had to do was change the resistor to 150ohm and it worked the same.

2. Anyone new to Arduinos / electronics who wants to build a similar device is going to have trouble without a schematic. In addition, they would be rather disappointed if they had used red LEDs instead of white. By providing details you are helping future adventurers.

I apologize, i kind of assumed that LEDs and current limiting resistors were pretty entry level knowledge. if someone is trying to get into this project and doesn't know at least that much then they should be starting on something simpler IMO.

Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. XD

This appears to be a good description of the problem...http://www.ti.com/lit/an/scba004c/scba004c.pdfI'm too lazy to read it thoroughly but from a cursory glance I gather the problem has to do with overheating caused by an input floating in the linear region of the transistor or from excessive switching. Neither of those is a problem for an AVR processor. Switching does burn energy but nowhere near enough to cause overheating problems.

In other words, floating inputs are most certainly not a problem for AVR processors. That's how they are initialized after a reset or power-up.