Model Scenery Tutorials

A Comprenshive Modeler's And Model Railroader's Guide

model scenery center

ATtiny

Programming an ATtiny microcontroller using an Arduino as an ISP (In-System Programmer) involves a few steps. Here’s a detailed guide on how to do it:

### Components Needed:
1. Arduino board (e.g., Uno, Nano, etc.)
2. ATtiny microcontroller (e.g., ATtiny85, ATtiny45, etc.)
3. Breadboard
4. Jumper wires
5. 10 µF capacitor (for stability, if needed)
6. Optional: 1 x LED and 1 x 220 ohm resistor (to test the setup)

### Step-by-Step Guide:

#### Step 1: Setup Arduino as ISP
1. **Connect the Arduino to your computer:**
– Open the Arduino IDE.
– Select the correct board and port (e.g., `Tools > Board > Arduino Uno`, and `Tools > Port > COMxx`).

2. **Upload the Arduino ISP sketch:**
– Go to `File > Examples > 11.ArduinoISP > ArduinoISP`.
– Upload this sketch to the Arduino.

#### Step 2: Connect the ATtiny to the Arduino
1. **Pin Connections:**
– Place the ATtiny on the breadboard.
– Connect the ATtiny pins to the Arduino as follows (assuming ATtiny85):

| ATtiny Pin | Function | Arduino Pin (Uno) |
|————|———-|——————-|
| 1 (RESET) | RESET | 10 |
| 2 | MOSI | 11 |
| 3 | (NC) | – |
| 4 | GND | GND |
| 5 | MISO | 12 |
| 6 | SCK | 13 |
| 7 | (NC) | – |
| 8 | VCC | 5V |

2. **Optional: Add a capacitor:**
– Place a 10 µF capacitor between the GND and RESET pins on the Arduino (negative lead to GND). This is to prevent the Arduino from resetting during the programming process.

#### Step 3: Configure the Arduino IDE for ATtiny
1. **Install ATtiny board support:**
– Go to `File > Preferences`.
– In the “Additional Board Manager URLs” field, add the following URL: `https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json`.
– Click `OK`.

2. **Open the Boards Manager:**
– Go to `Tools > Board > Boards Manager`.
– Search for “attiny” and install the `attiny by David A. Mellis`.

3. **Select the ATtiny board:**
– Go to `Tools > Board > ATtiny25/45/85`.

4. **Set the processor, clock, and port:**
– Set the processor (e.g., `Tools > Processor > ATtiny85`).
– Set the clock (e.g., `Tools > Clock > Internal 8 MHz`).
– Set the programmer (e.g., `Tools > Programmer > Arduino as ISP`).

#### Step 4: Burn the Bootloader (Set fuses)
1. **Burn the bootloader:**
– Go to `Tools > Burn Bootloader`.
– This sets the correct fuse bits on the ATtiny.

#### Step 5: Upload a Sketch to the ATtiny
1. **Write or open a sketch:**
– For testing, you can use the Blink sketch:
“`cpp
void setup() {
pinMode(0, OUTPUT); // Set pin 0 (physical pin 5 on ATtiny85) as an output
}

void loop() {
digitalWrite(0, HIGH); // Turn the LED on
delay(1000); // Wait for a second
digitalWrite(0, LOW); // Turn the LED off
delay(1000); // Wait for a second
}
“`

2. **Upload the sketch:**
– Select `Sketch > Upload Using Programmer` (or use the shortcut `Shift + Upload`).
– The sketch will be uploaded to the ATtiny.

#### Step 6: Test the Setup
1. **Connect an LED:**
– Connect the anode (long leg) of the LED to pin 0 of the ATtiny (physical pin 5).
– Connect the cathode (short leg) of the LED to a 220-ohm resistor, and then to GND.

2. **Power the ATtiny:**
– If not already powered, connect VCC and GND of the ATtiny to a 5V supply.

3. **Observe the LED:**
– The LED should blink on and off at 1-second intervals if the Blink sketch was uploaded successfully.

### Troubleshooting Tips:
– Ensure all connections are correct and secure.
– Verify that the ATtiny is getting the correct power supply.
– Double-check the pin configurations and connections.
– Make sure the capacitor is properly connected if used.
– Ensure the correct board, processor, clock, and programmer settings in the Arduino IDE.

This setup allows you to easily program the ATtiny using an Arduino, expanding the possibilities for your microcontroller projects.

Scroll to top