Here's another simple program that controls a stepper motor.
When I program, I like to get one small piece of the puzzle working and then start digging into the meaty bits. This is just a simple program that blinks and LED on PORTD. It's based on a 1ms Timer 0 interrupt. Good times.
AVR Pocket Programmer.
Pretty much all microcontrollers these days have In-System Programmers (ISPs) which allow new code to be programmed onto them while they are still in the system. This seems like an obvious thing, but I've had to work with microcontrollers and programmable logic devices that did not have ISPs. It was a pain in the butt to remove the chip from the circuit, plug it into a special programming socket, download the program, and then put the chip back into the circuit only to find a typo two seconds later and have to repeat the process.
The ISP allows that entire process to be avoided by programming the chip while it's still in the circuit and attached to all of it's other peripherals.
The ISP puts the program onto the microcontroller via the Serial Peripheral Interface (SPI) connection module of the ATMega328P. The Master-Out Slave-In (MOSI), Master-In Slave-Out (MISO) and Serial ClocK (SCK) lines do the heavy lifting of getting the code from the computer into the memory of the microcontroller. VCC provides +5V and GND is ground/common. RST connects to the reset pin of the microcontroller. The reset pin controls the state of the microcontroller. Without the reset held low (the reset pin is active low), the microcontroller will go on its merry way running the program already on it. It will just ignore the data coming down the SPI line as gibberish. However, with the reset held low, the microcontroller enters a programming state; wherein it listens to the data coming in on the SPI interface and programs itself.
Now that the physical connection from the computer to the microcontroller is set up, we can begin to program the micro to do interesting things.
I do quite a bit of microcontroller programming at school. However, the microcontroller we use at school has a nice development board with preloaded bootloader software.
1-4 of 4