Mikrokontroler, yah inilah dunia baru saya yang penuh dengan tantangan. Mungkin sebagian dari kita masih bingung, apa sih itu mikrokontroler…?, ehhmmm mikrokontroler adalah sebuah sistem mikroprosesor dimana didalamnya terdapat CPU, ROM, RAM, I/O, Clock dan peralatan lainnya yang dikemas dalam satu chip atau bisa juga dikatakan komputer versi mini… CMIW. Nah contoh sehari-hari dari implementasi mikrokontroler ini bisa kita lihat pada traffic light jalanan lalu lintas (lampu merah). Nggak percaya…? coba klo demo mahasiswa ikutan aja hancurin tuh traffic light n lihat isinya….hahhaha…
Nah… ini ada tutorial dasar mikrokontroler yang saya temukan dari blog mahasiswa india, tutorialnya bagus banget buat belajar dasar – dasar mikrokontroler berbasis avr. Bukannya gw malas atau plagiat yang cuma seenak jidat copas artikel orang, tapi belum ada waktu tuk benahin nih blog and artikelnya. silahkan dibaca…hehehe
Atmel has come up with a whole range of superb AVR microcontrollers which are the dream of every hobbyist. However, the real icing on the cake is that these µControllers can be programmed with just a parallel port connector and nothing else!!!. However, Atmel µC’s have their downsides too. They have to be programmed in either Assembly or in C. There is one program – Bascom AVR – which reportedly allows programming in BASIC. But, unfortunately it doesn’t seem to work (?) with the el-cheapo parallel port programmers . So, the only option left is C, unless you are willing to dabble with Assembly.
I’ll attempt to give a brief introduction to basic I/O operations in C for AVR microcontrollers.
First of all, you need a programmer to program. As i told you, its all very simple, you just need a parallel port cable. Follow this excellent tutorial by The Real Elliot at Instructables.com
So, first make a simple programmer, test out the blinking LED program and then come back.
PS: Your programmer doesn’t have to include all the header pins, a board etc, that Real Elliot has shown in his tutorial. A basic parallel port connector with a few wires and resistors soldered directly on it is what i have been using from the past couple of months. It works just as well.
Before starting, there are a few things i would wish to tell. First of all, at first sight , (especially to those unacquainted to C), all this “_BV(PD4)” stuff may seem a little too cryptic. At one point, you probably will be tempted to ditch GCC and learn Assembly. However, i assure you that Assembly is much more frightening than AVR C. AVR C is not at all hard to learn, it just looks a bit alarming because of those weird symbols like << >> ~ which keep floating around. Once, you understand what all that is about, it’ll all be a piece of cake.
What you should know before reading this tutorial:
1) I expect that you are somewhat well acquainted with atleast any 1 high level programming language. (BASIC, Java, C/C++ etc)
2) I expect that you are reasonably comfortable with the C syntax. You do not need to know all the stuff that comes in the 10th and 11th chapters of C++ books. Just the basics – Program syntax, header files, functions, if then else, loops – should be enough.
3) I expect you to be comfortable with binary numbers, logic gates and Boolean algebra.
If the answer to any of the above is no , then brush up and then come back.
I also recommend that everyone goes through this excellent pdf to brush up you C skills in case they are a bit rusty.
The Port Control Registers
For easier access , the I/O pins on an AVR uC are grouped into a number of ports. Each port contains a number of pins ranging from 3 to a maximum of 8. To control these Ports , 3 registers have been provided. Each register controls a specific feature of the Port. Let us examine each Register one by one.