loading
This instructable shows how to control a group of led's with one microprocessor output.

The micro I will be using is an Atmel Attiny2313.


Step 1: Parts and Tools

Parts:
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
Wire


Tools:
Soldering Iron

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.
its more like 7 pins than one pin, but good guide. isnt charlieplexing better than multiplexing though?
You probably want those LEDs facing the other way. In this diagram, they're reverse biased and won't light up.<br />
Whoops....it's fixed now.<br />
I'm not trying to be negative or anything, but the title is kind of misleading. You are not actually controlling the LED's with one output pin of the attiny2313. You are controlling each row of led's with it's own output pin, so you are actually using 7 output pins. To do it properly you would use a serial led driver chip like the A6279 from Allegro and use one output pin on the attiny2313 to send the serial data to the led controller. I am working with these chips and they are great. each chip controls 16 outputs and they are chainable to control even more led's.
You are right, I am only controlling 10 leds per output pin, but as I say later in this, you can have hundreds of leds or whatever you want, as long as your transistor or mosfet can handle it. It can be stepper motors, dc motors, 1000 leds, high power leds, whatever you want.
You can use simple shifting algorithm for moving <br/><br/>// code left shift<br/>byte = 0x01; //0b00000001<br/>for(x=0; x&lt;7; x++){<br/> PORT = byte;<br/> byte &lt;&lt; 1;<br/> _delay_ms(200);<br/>}<br/><br/>// code right shift<br/>byte = 0x40; //0b01000000<br/>for(x=0; x&lt;7; x++){<br/> PORT = byte;<br/> byte &gt;&gt; 1;<br/> _delay_ms(200);<br/>}<br/><br/>// code fill right<br/>byte = 0x40; //0b01000000<br/>for(x=0; x&lt;7; x++){<br/> PORT = byte;<br/> byte &gt;&gt; 1;<br/> byte |= 0x40;<br/> _delay_ms(200);<br/>}<br/><br/>REGARDS FROM BULGARIA<br/>
I am still new to C programming. All I really know is asm from school and that was on a Motorola micro. I have heard that if you know asm, C is much easier to learn though.
it is high level of programming :))) easy, fast ... only one is not so good when you write C the compiller transform this in asm /not so good like human / :) the programs are little bigger
I see you're using each bank the same colour, but beware of mixing colours within a bank as the perceived brightness of the various colours varies even though the current is the same. I found this in my <a rel="nofollow" href="https://www.instructables.com/id/How-To-Communicate-With-An-Alien-Artifact-or-/">recent Instructable</a> and used different resistor values to compensate. Green was the brightest, then blue, red, yellow (didn't use white). Experiment to get them matched up.<br/><sup>(BTW, your LEDs are drawn reversed in the schematic.)</sup><br/>
Yes, as I state later in the instructable, Blue LEDs usually drop around 3-3.3v, green is around 3-3.2v, and red is around 2.2v. I dont remember for the rest of the colors.
Agreed, but I'm saying something a bit different :<br/><br/>If you put (say) 15mA through a green, a blue, a red and a yellow LED (taking the Vf into consideration), the green will<strong> appear</strong> brighter than the blue, the blue brighter than the red etc. because of different efficiencies of the LEDs and the eye's sensitivity to the different colours. <br/>For my project, I initially did the calculations for the same current through each colour LED and found it no good at all, so I chose the resistor values by 'eyeballing' it.<br/><br/>
ok, yes, I know what you mean. For a school project we used a light meter to figure out exactly how to make them all look the same, but eyeballing it works the best because of the different wavelengths and how the human eye sees 555 nm the best.

About This Instructable

19,989views

40favorites

License:

More by jufreese:Control Anything with one AVR pin 
Add instructable to: