Micro-controller Programming

PCB Design

I used eagle to design my PCB. I found that after I got used to its interface, the work became really intuitive. As you can see below, i decided to use one switch and one led.


I generated a.png file and converted it to a path and then to a Modela file via the path tool chain. Unfortunately, after the milling, I discovered that some of the traces and pads were joined where as in my original design they were not. a quick investigation resulted in discovering that exporting a png file with resolution of 300 DPI will result in bad PCBs. Apparently you should create a png file with at least 1000 DPI in order for it to be milled properly. I tried to rescue the board with an exacto knife, but then I found that I had cut some of the traces. I tried to solder them as well, but this resulted in a big mess :( .I was forced to re-mill the board. The result can be seen below. Success at last.

My Application - The Drunko-Meter

I decided to design an application that would require only a button, a led and a terminal.

My choice was a Drunko-Meter. This application measures you response time by flashing a led randomly and timing your response (the time until you pushed the button). After a few tries, the application determines if you are drunk are not.

I found out the hard way why the ATtiny is indeed tiny. I decided to use the _delay_ms function in order to randomly space the led flashes. When I gave the function a parameter which contained the random integer ( _delay_ms(some_random_int) ), the following occurred:

It is better to always read the manual....

As can be seen from the note below, the parameters value  of delay_ms should be known at compile time, or otherwise your code ,may become bloated !

I remedied this by a loop which iterates a random number of times over the delay_ms() function.

The second pitfall I came across was when trying to use the random() function. It was also to large for the tiny’s tiny memory. so I had to create my own pseudo random function, which is basically an arbitrary list of numbers and each time the function is called, it gets the next one.

After those lessons, I finely managed to get the application to work !