It’s actually fairly easy, you must do precisely this. First, you will need to download the one of the files listed below, depending on which model attiny you’d like to use (I’d suggest installing them all, so it will be easy to change between microprocessors as the situation warrants.) For the example case, I will be using the attiny85, so, I will refer to the attiny45_85.zip file.
First, make sure the Arduino program is *not* currently running, if so, shut it down. Open your arduino folder (arduino_022, or whatever you’ve named it) and create a folder inside your sketchbook folder called hardware (if it does not already exist.) Extract the zip file, and copy the folder within to your newly created hardware folder. The arduino IDE is now prepared to program your attiny. If you have a stand alone ISP, skip down to the ‘my first ardutiny program’ below. Otherwise, you need to configure your arduino (or compatable) to program your bare attiny.
Fortunately, the arduino IDE comes with a sketch built in to handle this task. Connect your arduino, start up the IDE, and select the ‘Arduino ISP’ sketch from the examples menu. Upload the sketch to the arduino, and now were ready to wire this bad boy up.
The picture above shows my setup. Basically, you need to connect the attiny to power and ground, connect three of its pins (5, 6, and 7) to three of your arduino’s pins (11, 12, and 13) respectively. Connect the attiny pin 1 to the arduino’s pin 10; this will allow your attiny to be automatically reset as you program the microcontroller. *If you’re using a teensy or other ‘arduino-compatable’ your pins will be different. If you can’t work it out, feel free to contact me in the comments.*
Now, were ready to program. Select ‘attiny85 (w/ Arduino as ISP)’, open up the blink sketch from the examples, and hit program (likely some errors will pop up, ignore these, and carry on). Take a LED, and connect it as shown above, and watch it light up!
This allows the attiny to support the best arduino functions such as digitalWrite(), digitalRead(), analogRead(), analogWrite() this is our PWM! More on this in tomorrow’s article. It also is hip with the time based functionality, such as millis() and pulseIn() another very useful function to be covered this week!
Give your thanks to these folks, if they’re still listening, MIT HLT Lab, and Alessandro Saporretti. Questions, comments and hopefully plenty of b**ching in the comments below, por favor.
the avr motherlode