Intro: Control Anything With One AVR Pin
The micro I will be using is an Atmel Attiny2313.
Step 1: Parts and Tools
Attiny2313 (got 5 free samples from Atmel)
20 pin socket
Resistors (any size will work, depending on your setup. I will explain later)
5v regulator (any will work, I'm using an LM340)
Transistors or Mosfets (easiest to find and cheapest ones are usually 2n3904's. Just make sure it's an NPN transistor, or an N-Channel Mosfet)
2 small Capacitors (look up data sheet for regulator, .1uf and .22uf with LM340)
Lots of LED's
Some protoboard or a breadboard
Any programmer for the AVR
Step 2: Schematic and How It Works
The first schematic shows how I hooked up rows of led's to output pins. The output pin of the AVR goes to the base of a transistor, which is wired to work as a switch. When the output is low, or 0v, the transistor is off, and the current can't flow through the load to ground. When the output is high, or 5v, the transistor is on and current can flow through the load to ground. This is called low side switching, and can be used for led's, dc motors, stepper motors, and many other things that require more voltage or current than the micro can output.
The load for this project will be some led's.
The led's can be wired any way that you want, but the power supply you are using will determine how you can hook them up.
For me, I found a laptop charger which can output 16v at 7.5 amps max.
Now the most efficient way to hook up the leds was in a series parallel array as shown in the third picture.
To determine the resistor size, first find out how much voltage is dropped per led. For blue and green led's that I used, the voltage drop is around 3 to 3.3 volts. Red and yellow led's are around 2.2 volts.
Now add up all of the voltage drops in series (3*5=15v)
Now subtract that from your source voltage (16-15=1v)
Now you know how much voltage is dropped by your resistor (1v)
Now use ohm's law to solve for R: V=IR (1v=.015R)
*I used 15ma for my led's, this is typical for 5mm led's
So now each strand is using 15ma from your supply.
Each strand can be its own load, or you can attach as many together as you want, as long as the total current for that load does not exceed the limit for the transistor. (2n3904 can handle 100ma)
*The transistor can be replaced with an N-Channel Mosfet
Step 3: Build It
Now you can start breadboarding your circuit.
After I did a few tests on the breadboard, I soldered everything onto a protoboard.
If you wanted to get real fancy, you could layout your own board and etch it using one of the processes explained on this site.
Step 4: Program the AVR
Now it is time to program your AVR. If you don't know how to do this, check out this instructable: https://www.instructables.com/id/Ghetto-Programming%3a-Getting-started-with-AVR-micro/
Here is the program I made:
It just goes through a loop of sequences forever.
Once the AVR is programmed, you can stick it in the socket you soldered onto your board, or if you dont have a socket, check the program on a breadboard, and if it is correct, then you can solder the chip into your board.