Introduction: ATTiny Powered Arduino Projects - I Made It at TechShop
Arduino is a great platform. No question. But what if I told you that you could take your entire board and compact it into tiny package. And I mean really small. The chip in the picture is an ATTiny84, and that is the big version. So if your project only needs a few pins and isn't very complicated, this little chip and do it in a fraction of the space! Not only that, but each of these ATTiny chips are only $2 a piece.
Just another thing I made at TechShop.
http://www.techshop.ws
Just another thing I made at TechShop.
http://www.techshop.ws
Step 1: Materials
You will need:
An arduino uno
One of the following. All of these are 8bit microcontrollers as apposed to the 32bit chips in the standard Arduino platform. Whatever fits your needs. (I'm using an ATTiny84)
ATTiny44 - 4kb flash storage & 14pins
ATTiny45 - 4kb flash storage & 8pins
ATTiny84 - 8kb flash storage & 14pins
ATTiny85 - 8kb flash storage & 8pins
10microFarad capacitor
For the display, see this instructable
https://www.instructables.com/id/Arduino-powered-7-seg-LED-display-using-Shift-Regi/
An arduino uno
One of the following. All of these are 8bit microcontrollers as apposed to the 32bit chips in the standard Arduino platform. Whatever fits your needs. (I'm using an ATTiny84)
ATTiny44 - 4kb flash storage & 14pins
ATTiny45 - 4kb flash storage & 8pins
ATTiny84 - 8kb flash storage & 14pins
ATTiny85 - 8kb flash storage & 8pins
10microFarad capacitor
For the display, see this instructable
https://www.instructables.com/id/Arduino-powered-7-seg-LED-display-using-Shift-Regi/
Step 2: Setting Up the ATTiny Programmer
There are a couple of important steps to getting the Arduino to talk to the ATTiny. Essentially, we need to turn the arduino into an ISP or In System Programmer.
Make sure that you are using at least Arduino 1.0 IDE. This will not work on older versions.
Next download this file from github: https://github.com/damellis/attiny/tree/Arduino1
Now locate your arduino sketch folder. If it does not have the folder "hardware" there, create it now.
Put the attiny folder in that directory. It should look like Documents->Arduino->hardware->attiny
Reset the arduino program. Now when you open Tools->Board it should have the ATTiny boards as well.
Make sure that you are using at least Arduino 1.0 IDE. This will not work on older versions.
Next download this file from github: https://github.com/damellis/attiny/tree/Arduino1
Now locate your arduino sketch folder. If it does not have the folder "hardware" there, create it now.
Put the attiny folder in that directory. It should look like Documents->Arduino->hardware->attiny
Reset the arduino program. Now when you open Tools->Board it should have the ATTiny boards as well.
Step 3: The Circuit
Now we need to connect the ATTiny to the arduino.
On the Uno the connections are like this
Uno ATTiny
Pin13 -> SCK
Pin12 -> MISO
Pin11 -> MOSI
Pin10 -> RESET
And a 10microFarad cap across the Reset on the Uno to prevent it from just resting the bootloader immediately.
On the Uno the connections are like this
Uno ATTiny
Pin13 -> SCK
Pin12 -> MISO
Pin11 -> MOSI
Pin10 -> RESET
And a 10microFarad cap across the Reset on the Uno to prevent it from just resting the bootloader immediately.
Step 4: Getting Programs Onto the ATTiny
Now to program! With the ATTiny connected to the arduino for programming, set the board to ATTiny 84 (1Mhz).
Set the programmer to Arduino as ISP.
Upload the program you want onto the ATTiny. In this example, I'm using the Shift Register program from before. Located at the bottom.
You may get this warning. If that happens, that's OK. It worked.
ATtiny84
avrdude: please define PAGEL and BS2 signals in the configuration file for part
ATtiny84
If it doesn't work, try opening the ArduinoISP under example and running that on the Uno by itself. No wires or cap connected. Then retry programing the ATTiny board using
Remember, only the following arduino commands are supported:
pinMode()
digitalWrite()
digitalRead()
analogRead()
analogWrite()
shiftOut()
pulseIn()
millis()
micros()
delay()
delayMicroseconds()
SoftwareSerial (has been updated in Arduino 1.0)
*****************************************
//ATTiny
#define LATCH 6
#define CLK 7
#define DATA 8
//This is the hex value of each number stored in an array by index num
byte digitOne[10]= {0x6F, 0x09, 0x73, 0x3B, 0x1D, 0x3E, 0x7C, 0x0B, 0x7F, 0x1F};
byte digitTwo[10]= {0x7B, 0x11, 0x67, 0x37, 0x1D, 0x3E, 0x7C, 0x13, 0x7F, 0x1F};
int i;
void setup(){
pinMode(LATCH, OUTPUT);
pinMode(CLK, OUTPUT);
pinMode(DATA, OUTPUT);
}
void loop(){
for(int i=0; i<10; i++){
for(int j=0; j<10; j++){
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLK, MSBFIRST, ~digitTwo[i]); // digitTwo
shiftOut(DATA, CLK, MSBFIRST, ~digitOne[j]); // digitOne
digitalWrite(LATCH, HIGH);
delay(500);
}
}
}
Set the programmer to Arduino as ISP.
Upload the program you want onto the ATTiny. In this example, I'm using the Shift Register program from before. Located at the bottom.
You may get this warning. If that happens, that's OK. It worked.
ATtiny84
avrdude: please define PAGEL and BS2 signals in the configuration file for part
ATtiny84
If it doesn't work, try opening the ArduinoISP under example and running that on the Uno by itself. No wires or cap connected. Then retry programing the ATTiny board using
Remember, only the following arduino commands are supported:
pinMode()
digitalWrite()
digitalRead()
analogRead()
analogWrite()
shiftOut()
pulseIn()
millis()
micros()
delay()
delayMicroseconds()
SoftwareSerial (has been updated in Arduino 1.0)
*****************************************
//ATTiny
#define LATCH 6
#define CLK 7
#define DATA 8
//This is the hex value of each number stored in an array by index num
byte digitOne[10]= {0x6F, 0x09, 0x73, 0x3B, 0x1D, 0x3E, 0x7C, 0x0B, 0x7F, 0x1F};
byte digitTwo[10]= {0x7B, 0x11, 0x67, 0x37, 0x1D, 0x3E, 0x7C, 0x13, 0x7F, 0x1F};
int i;
void setup(){
pinMode(LATCH, OUTPUT);
pinMode(CLK, OUTPUT);
pinMode(DATA, OUTPUT);
}
void loop(){
for(int i=0; i<10; i++){
for(int j=0; j<10; j++){
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLK, MSBFIRST, ~digitTwo[i]); // digitTwo
shiftOut(DATA, CLK, MSBFIRST, ~digitOne[j]); // digitOne
digitalWrite(LATCH, HIGH);
delay(500);
}
}
}