How To: The Hardware Hacker's Introduction to Microcontrollers, Part One: Anatomy of an Arduino

The Hardware Hacker's Introduction to Microcontrollers, Part One: Anatomy of an Arduino

In this article, I'll be explaining the basics of how microcontrollers work, physically and virtually. First off, microcontrollers are no simple thing, so don't be discouraged if you find it mind-boggling! The world of microcontrollers is fascinating, engaging, and an awesome hobby; it never gets boring. I'll be focusing more on I/O and analog based microcontrollers, such as those running Arduino, and using Atmel chips as examples (these are most commonly available, and easy to program).

A common ATmega328 microcontroller, used in the Arduino unit depicted below.

What Is a Microcontroller?

A microcontroller is a silicone-based computer chip (or integrated circuit), that is programmed with a set of instructions. These instructions can range from as simple as blinking an LED, to dealing with mass amounts of data from a serial connection. The size of the microcontroller generally depends on the amount of pins and flash memory. For beginners, I'd recommend purchasing the Arduino Duemilanove, as it is inexpensive ($30) and very easy to use.

Advanced microcontroller users typically write their programs in C, then compile the finished script to a hex (hexadecimal) format. Finally, using a serial cable and AVR (or similar) programming software, users write or flash the data onto the chip itself through the SCK, MOSI, MISO, and RESET pins of the microcontroller (referred to as the SPI, or Serial Peripheral Interface Bus).

In the case of Arduino, the ATmega chip on the board itself contains a "bootloader", which understands and programs data through the UART, which is basically a telephone line between the computer and the board, the bootloader being the interpreter and recorder. The little silver rectangle (rounded edges) is a quartz crystal oscillator, which generates a frequency (in this case, 16 MHz). For accurate and precise serial communication, an external oscillator is practical.

AVR microcontrollers without a bootloader must be programmed through the SPI, as described above. All microcontrollers (at least, those with datasheets) have a pinout schematic and pin description. For example, below is the pinout and description for the ATmega328 described above.

The VCC is the positive power input (5V) and GND is the negative (or ground). Pins 17, 18, and 19 are used by the SPI to program the chip, if it does not have a bootloader. Digital pins are capable of both I and O interfaces, in other words, they can either output power (ex. light an LED), or receive power (ex. identify if a switch is at a high or low state/on or off).

Analog pins are more complicated, as they collect multiple forms of data over a large span of voltage readings. For example, analog pins can determine "digital" specific voltage being inputted.

The AREF pin (21, analog reference) is used as the max value, or highest value measured, represented by the digital value 1023. Any values in between 0 and the reference voltage are represented with values between 0 and 1023.

Warnings

  • Microcontrollers can fry very easily! Ensure that you NEVER insert/attach with incorrect polarity, or to incorrect pins.
  • Microcontrollers are sensitive to static electricity, always employ static-protection (grounded wristband).
  • Microcontrollers are FRAGILE! Treat them with care.

Now,head on over to part two, which digs deeper into the mysteries of microcontroller programming!

Just updated your iPhone to iOS 18? You'll find a ton of hot new features for some of your most-used Apple apps. Dive in and see for yourself:

Image by bigthink

3 Comments

I'm kind of excited for part 2 I've had an Arduino Duemilanove for quite some time, I've just never found some where that breaks it down and explains it.

While Tinkering with the plastic cover off of my Amiga 500, I incidentally and accident....ally touched on one of the Fat Agnus soldiered pins... The surge was horendous, and in a nano sec. or so the Fat Agnus chip was a rocketing turbo rocket headed for i'd say out my ceiling at least it tried to. POPPPPP loud POP, the very center of the chip overheated so fast and with such force, the silicon Crater was beveled a round bevel that exposed the very metallic innerds that made up the micro chip switching of the Fast Agnus. I was grateful i ws not directly above it when it exploded, and yes very stupid of me to be tinkering on the board with power to it. That was enough of a lesson for me to NEVER have a metal tools of any kind in my hand anywhere around a live circuit board or any other electronic equipment feeding on unbound surging energy throughout it. That was back in the late 1980's early 1990's, Not since then have I destroyed and micro chips, however one incident 7 years ago I did not compared ddr memory modules in my friends p4 2ghz intel desktop pc, and well the slits in the board the guide a person as to how they will and will not go in, well I paid no attention and inserted it forced it just a tad bit anyway, then the end lock clips would not click down properly until i forced just a hair more then they clicked down, minus a logically functioning and patient rational thinking brain at the time i powered it on, and that's all it took to fry god only knows what out on his motherboard.... The PC never booted after goign black, removed the module, realized what a stupid thing i had done and tried a proper one, well too damn late mobo was fried, at least some components were, so easier just to spend the 50-78$ for a new one then investigate solider desoldier chips, capcitors, etc... so yes the END GAME was about 4 months ago I ( now knowing what I am doing for most all parts, Had the need to flash my bios so that my hardware(s) would be fully supported. Ok so I

will this ridiculous momentary lapse of reason be costing me? 178$ he said. Oh cool so Your going to be paying the bill for me then right? Well of course not sir... I said that's the most ridiculous thing i ever heard of me sending you my 78+ pound desktop PC just to replace the bios chip, Your off your rocker pal, Where can I get one, afterall You guys made my motherboard You are ASUS! We don;t have them sir, that;s a factory installed item. PFFFFFFFFT, i see, so it's all about how much You can milk me of the money I don't have to begin with then I know all about it.... Piss off #$%@!+*, I will find it myself. And in that instance, i slammed the phone down, and already brought up my search engine to reveal the chip i need just happens to be made readily available by a gentleman on ebay, totalling 18$ with tax. Cool so i ordered it, got it 5 days later studied the chip placement, did what I had to and had my pc back up in a matter of 20+ minutes or so.... Gee Thanks Asus You make rock sold heart touching motherboards most definitely but customer service leaves something to be desired, specially when the goal is to money monger from the poor suppression of the poor to make the rich even richer, And that's my evolution of: being an "Avid PC Enthusiast Since 1982..."

StanDP AKA PRiME.TarGET.(o )( o).

Share Your Thoughts

  • Hot
  • Latest