Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to solder)
1. Hacking Cool things
With
Microcontrollers!
Mitch Altman
Chief Scientist, Cornfield Electronics, San Francisco, CA USA
Author of The Brain Machine in MAKE Magazine #10
Inventor of TV-B-Gone universal remote control
email: mitch@CornfieldElectronics.com
site: www.CornfieldElectronics.com
Codebits
November 14, 2008
10. What is a Microcontroller?
A complete computer on a chip (with a little extra stuff)
RAM
Program
Processor
Memory
Inputs
Input/Output
Outputs
Timers
11. What Does a Microcontroller Do?
Like all computers:
Fetch Instruction
Execute Instruction
Repeat forever (till power goes off)
12. How to Make Cool Things with
Microcontrollers
• Idea
• Hardware
• Firmware
• Coolness!
14. Hello World – Hardware
Battery +
Resistor LED
Microcontroller Battery -
Battery -
15. Hello World – Digression:
(Very) Basic Electronics Lesson
Electronics: electrons flowing through wires and parts
(sorta like water flowing through pipes)
Current -- speed of electrons flowing
Battery -- like a pump pushing electrons
Resistor -- like a kink in a pipe, slows down electrons
Diode -- one-way valve for current
LED -- special diode: emit photons when current flows
Transistor -- remotely controlled switch
Microcontroller -- zillions of transistors!
16. Hello World – Firmware
Assign a value to a variable:
Software: X = 00000001
Firmware: X = 00000001
17. Hello World – Firmware
Changing an output pin:
PortA = 00000001
PortA = 00000000
18. Hello World – Firmware
Changing an output pin (using manual delay):
PortA = 00000001
Call Delay
PortA = 00000000
-----------
Delay:
Count = 0
Wait:
Count = Count + 1
If Count < 10,000 goto wait
Return
19. Hello World – Firmware
Changing an output pin (using hardware timer):
Main:
Call Init
PortA = 00000001
Call Delay
PortA = 00000000
Sleep
-----------
Delay:
Timer0 = 60,000
Wait:
If Timer0flag = 0 goto wait
Return
20. Hello World – Firmware
Advanced topic:
Changing an output pin (using interrupts):
Main:
Call Init
PortA = 00000001
Call Delay
PortA = 00000000
Sleep
-----------
ISR: Delay:
TimeFlag=1 Timer0 = 60,000
Wait:
Return If TimeFlag = 0 goto wait
Return
21. Hello World – programming your chip
Use software on your computer
Text Editor
Compiler
Programmer
Specific software Depends on your microcontroller
PIC, AVR, etc.
Need hardware programmer (often very cheap)
22. Real Project: Ladyada’s MiniPOV3
Just like “Hello World”,
but 8 LEDs and different timing
Etc…
23. Hacking! :
The easy way
to make your cool microcontroller projects
30. Hacking!
LED Cube from MiniPOV3 kit
(First NYC Resistor Project)
31. Hacking!
Brain Machine from MiniPOV3 kit
Synchronizes your brain to a desired brainwave sequence
(and hallucinate along the way!)
WARNING: Blinking lights are not good for people with epilepsy
36. Hacking Cool things
With
Microcontrollers!
Mitch Altman
Chief Scientist, Cornfield Electronics, San Francisco, CA USA
Author of The Brain Machine in MAKE Magazine #10
Inventor of TV-B-Gone universal remote control
email: mitch@CornfieldElectronics.com
site: www.CornfieldElectronics.com
Codebits
November 14, 2008