The first tutorial that pretty much everyone covers is the “Hello World” tutorial of physical programming … connecting a single LED to the microprocessor and causing it to blink.
This is a very simple project and the outlook is sunny.
For this tutorial, you will need to prepare your ATTiny85 with the Blink sketch that comes with the Arduino IDE. This sketch uses the Arduino Pin 13 as the output pin, however, the ATTiny85 doesn’t have a Pin 13. To hook up our ATTiny85, we’re going to need to work out which pin would be compatible with the Arduino Pin 13. So … what are the characteristics of Arduino Pin 13? Pin 13 kinda special, apart from being a Digital interface, it is also an SPI pin (MOSI – Master Out Slave In) for asynchronous communication … typically used for data connection, like when you are connecting your ATTiny85 to the ATMegaxxxx for programming. For this tutorial, you don’t need to access that functionality, but we are looking for a Digital pin on the ATTiny85
The above shows the pinout scheme for the ATTinyx5. We could use PCINT0, PCINT1, PCINT3, PCINT4 or PCINT5 (or … any pin that isn’t VCC or GND). For simplicity sake, we’ll use PCINT0.
Having decided on which pin we are going to use as output in our experiment the next step is to change the example sketch.
Open the example sketch File > Examples > 01. Basics > Blink in the Arduino IDE
The sketch that is loaded is the basic blink sketch
The only change that needs to be made to the example sketch is the pin variable
So you change:
int led = 13;
to
int led = 0;
And then you can upload the sketch to the ATTiny85 (remembering to first set up the Arduino as an ISP as per the previous article (Arduino as ISP for ATTiny85).
When the sketch is loaded, you can pop the chip out of the ISP shield and put it in your breadboard as per the following diagram.
By convention, I’m using the Fritzing example 5V regulator (with the added 9V battery) to show the input source. Practically, I use my 5V regulator board from my previous article in it’s place.
The ATTiny85 is oriented with the dot bottom left, make sure that you orient your chip and connections correctly.
A jumper wire connects PCINT0 to the LED anode and the LED cathode is connected to the GND rail via a resistor (I’m using a 220 ohm resistor, but you should use the correct resistor for your LED).
When the power is connected, the LED blinks.
That concludes the first tutorial. I recommend that you also read the Freetronics tutorial so that you can compare the ATTiny85 implementation with the UNO clone implementation.
Check out the rest of the tutorials here.
No comments:
Post a Comment