Week 13

Output devices.

Output Devices

The assignment is to add an output device to the microcontroller and program it to do something. I wanted to make a led matrix using charlieplexing technique.

Concept

The idea is to utilize i/o pins to control leds more than its number. Each pin can supply and sink current. We use one pin to supply and as many pins as you have to sink current. So in my case i will use only 3 pins to control 6 LEDs.

...

Circuit Design

I'm going to use attiny45 microcontroller with 6 LEDs and power on LED.

... ...

Download the eagle files.

ledmatrix.sch
ledmatrix.brd

Download the exported images

ledmatrix_traces.png
ledmatrix_interior.png

Machining and soldering

... ...

Programming - part 1 - selectring one LED every time

The code is select a LED and set the anode port pin as HIGH and the cathode port pin as LOW.

...

Download the source code:

ledmatrix_V1.c
ledmatrix_V1.c.make

Compile the code by writing make -f ledmatrix_V1.c.make

Upload the HEX file by writing make -f ledmatrix_V1.c.make program-usbtiny

Testing

It worked as expected. Here's a video :

Fab Academy - Week 13 - Output devices from Mohamed Kamel on Vimeo.

More than displaying one LED

I wanted to be able to display any number of leds at the same time. In the previous example if i decreased the delay enough between every led, we will be able to see the whole LEDs on. That's because our eyes are not fast enough to catch the change. So i used the same concept to display different patterns.

I setup a simple interrupt for the counter overflow. Everytime the counter overflows i increment a variable when the variable reaches a threshold (a certain amount of delay between every pattern) it switches to the next pattern and reset the counter.

...

Download the source code:

ledmatrix_V2.c
ledmatrix_V2.c.make

Compile the code by writing make -f ledmatrix_V2.c.make

Upload the HEX file by writing make -f ledmatrix_V2.c.make program-usbtiny

Testing

Notice that you can't turn more than two leds at the same time without this approach. But now i can even turn on all of the leds.

Fab Academy - Week 13 - Output devices - LED matrix from Mohamed Kamel on Vimeo.



Thanks for passing by!