Carlos Herbozo Vidal

Former child. Coffee enthusiast

Week 9: Embedded Programming


This week's assignment was to program a board which I had already manufactured. I decided to use my modified "Echo-Hello World Board" from Electronics Design and my FabISP from Electronics Production.




It turns out, that my hello board had some problems, so I had to remake it and resolder everything. In order to make it properly, I checked the DataSheet, available here.




The most important thing to consider, is which pins can be used as digital inputs and outputs, and which can be used as analog inputs and outputs. Also, the fact that the pins are numbered differently in the Attiny and the Programming environment.


Anyway, back to programming my Hello Board. I used the Arduino IDE, because I had previously worked with it at work. I realize that I could have done it differently, but I did not have much time this week, so I took the easy path. Within the Arduino IDE, I followed these steps in order to burn the bootloader to my Microcontroller, and allow it to understand the language.


  1. Click ion Tools
  2. Select ATtiny24/44/84 as your "board"
  3. Select ATtiny44 as your "Processor"
  4. Select External 20 MHz as your "Clock"
  5. Click on Burn Bootloader


Finally, upload the code. I decided to use the Blink example to test whether or not the Led on my Hello Board worked. And it did!





Basically the code has two parts:


  1. Void Setup: Here I define the variables and the pinMode. This means I get to say which pins within the ATtiny work either as INPUT or OUTPUT. I also set the baud rate, which I won't need for this example.
  2. Void Main: Here the code runs endlessly in a loop. What this particular code does is turn on and off the LED with one second intervals, so as to generate a blink effect.


I wanted to try some different things, so I decided to program the board with some code of my own. It's not very original, but the idea is that the LED lights up only when the button is beign pressed. Here's an image and a video of how it works.




The code can be found here.


Update: C-code


After my feedback, I was asked to program my board with at least another programming language. Nicolas had the same issue, so we decided to work on it together. We both set out to try and program our boards with C/C++ because it is what the Arduino language, with which we are both familiar, is based on. I looked at this page from a previous fab-academy student and tried to learn what he had done. So, Nicolas and I wrote our C code and tested that it compiled within the Arduino IDE.



So what the code does is basically define the pin where the LED is stationed and then turn it on and off continiously for 1 second, looping endlessly. The "While(1)" and "Return(1)" statements allow for an endless loop. All in all, C programming wasn't as hard as I had expected. Here's a link to my code


I could not find my original Hello Board, so I programmed my Input devices board.



Footnote


I also wanted to try programming a more complex board, so I checked the Satsha Kit and tried to replicate it. I modified it a little bit, by changing the crystal component and removing a couple of capacitors, I also redrew the board, using thicker traces (0.6), so as to avoid problems during cutting, in the end, I did not test its functioning, but i'll keep the board just in case.