Instructables

Simplest and Cheapest Arduino

Step 6: Uploading Arduino sektch to ATtiny85

Picture of Uploading Arduino sektch to ATtiny85
Here is the sketch for 5 channel running light sketch, you must upload to the ATtiny85.

/ / The sketch demonstrate a 5 channel running light using ATTiny45/85 micro controller

# Define CH1 0 / / ATTiny45/85 PIN5
# Define CH2 1 / / ATTiny45/85 PIN6
# Define CH3 2 / / ATTiny45/85 PIN7
# Define CH4 3 / / ATTiny45/85 PIN2
# Define CH5 4 / / ATTiny45/85 PIN3

long interval = 1000; / / set the LED blink speed (1000ms = one second)

void setup ()
{
pinMode (CH1, OUTPUT); / / set CH1 as output
pinMode (CH2, OUTPUT); / / set CH2 as output
pinMode (CH3, OUTPUT); / / set CH3 as output
pinMode (CH4, OUTPUT); / / set CH4 as output
pinMode (CH5, OUTPUT); / / set CH5 as output
}

void loop () {
digitalWrite (CH1, HIGH); / / set the LED on
delay (interval); / / wait for a second
digitalWrite (CH1, LOW); / / set

digitalWrite (CH2, HIGH); / / set the LED on
delay (interval); / / wait for a second
digitalWrite (CH2, LOW); / / set the LED off

digitalWrite (CH3, HIGH); / / set the LED on
delay (interval); / / wait for a second
digitalWrite (CH3, LOW); / / set the LED off

digitalWrite (CH4, HIGH); / / set the LED on
delay (interval); / / wait for a second
digitalWrite (CH4, LOW); / / set the LED off

digitalWrite (CH5, HIGH); / / set the LED on
delay (interval); / / wait for a second
digitalWrite (CH5, LOW); / / set the LED off
}


Follow step below to upload sketch to ATtiny85
1. Comeback to the Arduino software and select File>New from menu
2. Copy above running light source code to your Arduino work space.
3. Click on Tools>Board>ATtiny85 (w / Arduino as ISP) as shown in figure below
4. Click the Upload icon to begin upload Sketch to ATtiny85

 
Remove these adsRemove these ads by Signing Up
Mudbud1 year ago
You can make the code smaller with a for loop.