This post is Round Two of my quest to use my older AVR chips using the Arduino IDE as a programming platform and an Arduino Uno as a programmer ..
Originally, I was using a library (written originally for Arudino IDE 1.0.x) by David Ellis, from back in 2005. This DID work, for the fader program below and in the previous post, but that library only supported a few chips, and I was worried that as I tried to do more advanced things (using the ADC, SPI, or I2C stuff) I would run into problems. And I would like to buy/use the tiny44/84, 2313/4313, 861, and others eventually as well.
In any case...Spence Konde has created a 'modern' ATtiny library that has a lot more chips and functional support. To get it, open the Arduino IDE and then hit File/Preferences. Click on the little 'edit' button to the right of the 'Additional Boards Manager URLs:' field, and cut and paste the following...
...onto the list of sources for third-party board descriptions. Hit OK, then OK again on the Preferences dialog. Then go to the Tools/Board.../Board Manager (at the very top of the list)....scroll around until you find the ATtinyCore Modern package by Spencer Konde (ver 1.1.1 is the latest). Highlight and install it, and then quit the Board Manager.
Now, BEFORE you start writing a program for an ATtiny, make sure the Ardiuno ISP software is loaded on the Arduino, which is Example 11 in the File/Examples menu. Burn that, and then open/write your ATtiny program. When you are ready to burn your ATtiny....
You'll now have LOTS of new options under Tools/Board below the standard Arduinos....Choose the board series (ATtinyx5 in my case) off from the ATtiny list, and then you will have the B.O.D./power options (disable if yer not sure), Timer 1 Clock (not sure so I dint mess with it), Chip selection (tiny45), and Clock (lots of new options, but mine was already set on 8Mhz internal).
To burn a program (like 'fader' below)...wire up the ISP pins from the Arduino to the chip in question. Spencer Konde also recommends a 0.1 uF capacitor across the VCC/GND on the chip just for safety sake. Next, make sure you choose the Arduino/Leo as ISP (ATtiny) off the programmer list. Other options may work, but I know that one does the job.
Lastly...if you need to know all about this library, Spencer Konde has an excellent README for it here:
ATTinyCore/README.md at master · SpenceKonde/ATTinyCore · GitHub
/*
LED Fader for tiny45
*/
//
// NOTES for uploading: use the ATtinyCore Universal library
// (http://drazzy.com/package_drazzy.com_index.json)
// with ATtiny x5 series, then the chip, speed, etc. and use the
// Arduino/Leo as ISP (ATtiny) as the programmer.
//
// You can also change the internal clock, B.O.D., voltage
// standard fuses by choosing the option
// you want and choosing 'Burn Bootloader'. Be Careful!
//
//
#define FADEPIN 1
unsigned char fcnt = 0;
char fpause = 7;and
char updn = 1;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(FADEPIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
fcnt += updn;
analogWrite(FADEPIN, fcnt); // turn the LED on (HIGH is the voltage level)
delay(fpause); // wait for a second
if (fcnt > 254) updn = -1;
if (fcnt < 1) updn = 1;
}
No comments:
Post a Comment