Programming ATtiny85 with Arduino Software

Programming an ATtiny85 with Arduino

I am currently working on this LED bar and I ran into, let's say a problem. Up here I want to use my WS2801 LED strip to play some different animations which I want to cycle through with a push button.

This project requires a separate microcontroller for the LED strip, which will be an ATtiny85. The ATtiny85 is a smaller and more affordable option compared to the Arduino Uno's ATmega 328.

Why Choose ATtiny85?

  • Cost-effective (around $1)
  • 5 IOs, sufficient for this project
  • 8 kilobytes of flash memory, enough space for some animations

Software Requirements

To program the ATtiny85 using Arduino software and an Arduino Uno as a programmer, you need to:

  1. Download and install Arduino software (version 1.0.5)
  2. Download board data for the ATtiny from HiloTech.org
  3. Extract the zip archive and copy the ATtiny folder into the Arduino hardware folder

Hardware Requirements

  • ATtiny85 IC
  • Arduino Uno (as a programmer)
  • 10uF capacitor
  • Jumper wires

Wiring the ATtiny85

Connect the Arduino pins to the ATtiny85 IC as follows:

  1. Arduino pin 13 to ATtiny IO 2
  2. Arduino pin 12 to ATtiny IO 1
  3. Arduino pin 11 to ATtiny IO 0
  4. Arduino pin 10 to ATtiny reset pin 1
  5. 5V from Arduino to ATtiny VCC (pin 8)
  6. Ground from Arduino to ATtiny ground (pin 4)

Programming the ATtiny85

Select the Arduino ISP as programmer and ATtiny85 with a clock of 1MHz as the board. Upload your sketch to the ATtiny85.

Example Sketch: Blinking LED

A simple blink sketch for an LED on IO 3 of the ATtiny85:

// Define the LED pin
const int ledPin = 3;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  digitalWrite(ledPin, HIGH);   // Turn the LED on
  delay(1000);               // Wait for 1 second
  digitalWrite(ledPin, LOW);    // Turn the LED off
  delay(1000);               // Wait for 1 second
}

ATtiny Programming Shield

Create a programming shield using a PCB and male headers. Connect the Arduino pins to the ATtiny85 IC using bridge wires.

Bitbanging SPI Protocol

Use bitbanging to emulate the SPI protocol, necessary for the WS2801 LED strip.

Conclusion

This project demonstrates how to program an ATtiny85 using Arduino software and an Arduino Uno as a programmer. The ATtiny85 is a cost-effective option for small projects, and bitbanging can be used to emulate the SPI protocol.



ATtiny Programming
The ATtiny is a series of small, low-power microcontrollers developed by Atmel (now Microchip Technology). The ATtiny microcontrollers are designed for use in applications where space and power consumption are critical factors. They are often used in wearable devices, robotics, and IoT projects.
Background
The ATtiny microcontrollers were first introduced by Atmel in the early 2000s. They were designed to be a compact and low-power alternative to traditional AVR microcontrollers, such as the Arduino Uno. Since then, the ATtiny series has expanded to include several models with varying amounts of flash memory, SRAM, and I/O pins.
Programming
ATtiny microcontrollers can be programmed using a variety of methods, including:
• Arduino IDE: The ATtiny series is supported by the Arduino IDE, making it easy to program and develop applications.
• Atmel Studio: A free, integrated development environment (IDE) provided by Microchip Technology for developing and debugging ATtiny applications.
• avr-gcc: The GNU Compiler Collection (GCC) for AVR microcontrollers can be used to compile and program ATtiny devices.


Programming ATtiny85 with Arduino Software

Introduction: The ATtiny85 is a small, low-cost microcontroller developed by Atmel. It has 8KB of flash memory and 512 bytes of SRAM, making it suitable for small projects that require a simple microcontroller. One of the challenges in using the ATtiny85 is programming it. In this article, we will explore how to program the ATtiny85 using the Arduino software.
Materials Needed:
  • ATtiny85 microcontroller
  • Arduino Uno or other compatible board
  • Breadboard and jumper wires
  • USB cable for programming
Setting up the Arduino Environment: To program the ATtiny85 using the Arduino software, we need to set up the environment. We will use an Arduino Uno as a programmer for the ATtiny85.
  1. Connect the Arduino Uno to your computer via USB.
  2. Open the Arduino IDE and select "Tools" > "Board" > "Arduino Uno".
  3. Select "Tools" > "Processor" > "ATtiny85".
Burning the Bootloader: Before we can upload sketches to the ATtiny85, we need to burn a bootloader onto it. The bootloader allows us to upload sketches using the Arduino IDE.
  1. Connect the ATtiny85 to the breadboard.
  2. Connect the VCC pin of the ATtiny85 to the 5V pin on the Arduino Uno.
  3. Connect the GND pin of the ATtiny85 to the GND pin on the Arduino Uno.
  4. Select "Tools" > "Burn Bootloader".
Uploading Sketches: Now that we have burned a bootloader onto the ATtiny85, we can upload sketches using the Arduino IDE.
  1. Create a new sketch in the Arduino IDE.
  2. Select "Tools" > "Board" > "ATtiny85".
  3. Select "Sketch" > "Upload Using Programmer".
Tips and Variations: Here are some tips and variations to keep in mind when programming the ATtiny85 with Arduino software.
  • Use an external crystal oscillator for more accurate timing.
  • Use a voltage regulator to supply power to the ATtiny85.
  • Use a programmer such as the USBasp or AVR ISP MKII for more reliable programming.
Conclusion: Programming the ATtiny85 using Arduino software is a convenient and cost-effective way to develop small projects. By following these steps, you can unlock the full potential of this tiny microcontroller.


Q1: What is ATtiny85? The ATtiny85 is a small microcontroller developed by Atmel, which can be programmed using the Arduino software.
Q2: How do I program ATtiny85 with Arduino software? You need to use a USB programmer or an Arduino board as an ISP (In-System Programmer) to upload the sketch to the ATtiny85.
Q3: What are the steps to program ATtiny85 using Arduino software? First, install the ATtiny85 board definition in the Arduino IDE. Then, select the ATtiny85 board and the correct programmer. Finally, upload your sketch.
Q4: What are some popular programmers for ATtiny85? Some popular programmers include USBasp, AVRISP mkII, and Arduino Uno/Mega/Nano as an ISP.
Q5: Can I use the Arduino Uno as a programmer for ATtiny85? Yes, you can use the Arduino Uno (or Mega or Nano) as an ISP to program the ATtiny85.
Q6: How do I install the ATtiny85 board definition in Arduino IDE? Go to File > Preferences, and add the URL of the ATtiny85 board definition repository. Then, go to Tools > Board > Boards Manager, and install the ATtiny85 board.
Q7: Can I use all Arduino libraries with ATtiny85? No, not all Arduino libraries are compatible with ATtiny85 due to its limited memory and resources. Some libraries may need modifications or optimizations.
Q8: How do I debug my ATtiny85 program using Arduino software? You can use the Serial Monitor in Arduino IDE to print debug messages, but you'll need to add a serial communication library compatible with ATtiny85.
Q9: Can I use interrupts on ATtiny85? Yes, the ATtiny85 has two external interrupt pins (PB2 and PB3) that can be used with the Arduino attachInterrupt() function.
Q10: What is the maximum clock speed of ATtiny85? The maximum clock speed of ATtiny85 is 20 MHz, but it can be configured to run at lower speeds using the Arduino software.




Pioneers/Companies Contributions
1. David A. Mellis Created the Arduino-Tiny core, allowing ATtiny85 programming with Arduino IDE.
2. Adafruit Industries Developed the Gemma and Trinket boards, popularizing ATtiny85 use in wearable tech and DIY projects.
3. SparkFun Electronics Released the Tiny AVR Programmer, a popular tool for programming ATtiny85 chips.
4. High-Low Tech Created the ATTinyCore, an Arduino core specifically designed for ATtiny85 and other small AVR microcontrollers.
5. MIT Media Lab Used ATtiny85 in various wearable tech and sensor projects, showcasing its potential in innovative applications.
6. Limor "Ladyada" Fried Developed the Gemma board and wrote extensively on programming ATtiny85 with Arduino, inspiring a community of makers.
7. Nathan Seidle Fostered the development of SparkFun's Tiny AVR Programmer and promoted ATtiny85 use in DIY electronics projects.
8. Arduino LLC Supported ATtiny85 programming through their IDE, enabling a broader audience to explore its capabilities.
9. Atmel Corporation (now Microchip Technology) Manufactured the ATtiny85 chip and provided documentation, making it accessible to hobbyists and professionals alike.
10. The open-source community Contributed to the development of various libraries, examples, and tutorials, facilitating the adoption of ATtiny85 in diverse projects.




Section Description
Hardware Requirements
  • ATtiny85 microcontroller
  • Arduino IDE (version 1.6.x or later)
  • USBasp or other AVR programmer (optional)
  • Breadboard and jumper wires for prototyping (optional)
Software Requirements
  • Arduino IDE (version 1.6.x or later) with ATtiny85 support
  • Avrdude (version 5.10 or later) for programming the ATtiny85
  • Optional: Arduino Core for ATtiny85 (for more advanced features)
Board Configuration To program the ATtiny85 with Arduino, you need to configure the board settings in the Arduino IDE:
  1. Open the Arduino IDE and go to Tools > Board > Boards Manager...
  2. Search for "ATtiny" and install the "ATTinyCore" by David A. Mellis
  3. Select the ATtiny85 from the "Tools > Board" menu
Uploader Settings To upload sketches to the ATtiny85, you need to configure the uploader settings:
  1. Open the Arduino IDE and go to Tools > Programmer > USBasp (or other AVR programmer)
  2. Select the correct baud rate for your programmer (e.g., 9600)
Sketch Upload To upload a sketch to the ATtiny85:
  1. Create a new sketch in the Arduino IDE or open an existing one
  2. Verify the sketch by clicking on the "Verify" button or pressing Ctrl+R (Windows) or Cmd+R (Mac)
  3. Upload the sketch to the ATtiny85 by clicking on the "Upload" button or pressing Ctrl+U (Windows) or Cmd+U (Mac)
Serial Communication The ATtiny85 has a limited serial communication capability. You can use the SoftwareSerial library to establish a serial connection:
  • In your sketch, include the SoftwareSerial.h library: #include
  • Create a SoftwareSerial object and define the RX and TX pins: SoftwareSerial mySerial(0, 1); // or other available pins
Pinout and Pin Modes The ATtiny85 has a total of 8 pins. You can configure the pin modes using the Arduino IDE:
  1. Digital I/O: Use the pinMode(), digitalRead(), and digitalWrite() functions
  2. Analog I/O: Use the analogRead() function (only available on pins 2, 3, and 4)