Simplest and Cheapest Arduino
by smching in Circuits > Arduino
92572 Views, 206 Favorites, 0 Comments
Simplest and Cheapest Arduino
Use a ATTiny85 (can be ATTiny45, ATTiny44) to make an Arduino just for US3.00 and name it as Tiny Arduino.
Tiny Arduino have only eight pins as shown in figure above, Pin4 is ground (Gnd), Pin8 is 5V (Vcc), Pin1 is Reset, Pin2 and Pin3 originally used to connecting the Crystal. In order to utilize all the IO, the internal oscillator (RC Oscillator) is used to replace the external clock which require a crystal. Therefore the Tiny Arduino is now come with five IO. Below shows the Arduino IO functions.
1. There are five IO, each IO can be Input or Output
2. Among the five IO, two of the IO can perform as PWM
3. Among the five IO, three of the IO can perform as Analog Input
I2C may require to extend the features of Tiny Arduino.
Tiny Arduino have only eight pins as shown in figure above, Pin4 is ground (Gnd), Pin8 is 5V (Vcc), Pin1 is Reset, Pin2 and Pin3 originally used to connecting the Crystal. In order to utilize all the IO, the internal oscillator (RC Oscillator) is used to replace the external clock which require a crystal. Therefore the Tiny Arduino is now come with five IO. Below shows the Arduino IO functions.
1. There are five IO, each IO can be Input or Output
2. Among the five IO, two of the IO can perform as PWM
3. Among the five IO, three of the IO can perform as Analog Input
I2C may require to extend the features of Tiny Arduino.
Materials
1 x 5V power supply power supply
1 x Breadboard (Project board)
1 x ATtiny85 (This is our Tiny Arduino)
1 x Arduino Duemilanove (use to upload Sketch to ATTiny85)
1 x 10 uF capacitor (prevent Arduino duemilanove from automatically reset)
5 x LED
5 x Resistors
and some Wires
1 x Breadboard (Project board)
1 x ATtiny85 (This is our Tiny Arduino)
1 x Arduino Duemilanove (use to upload Sketch to ATTiny85)
1 x 10 uF capacitor (prevent Arduino duemilanove from automatically reset)
5 x LED
5 x Resistors
and some Wires
Using an Arduino Duemilanove As an ISP
An ISP (in-system programmer) is required to upload sketch to the ATtiny85 since ATtiny85 does not come with serial interface. Here we use an Arduino Duemilanove as an ISP to upload sketch to the ATtiny85.
1. Connect the Arduino Duemilanove to the computer
2. Open the Arduino software , I'm using arduino-0023
3. Select File> Examples> ArduinoISP from menu as shown in figure
4. Select Tools> Board> Arduino Duemilanove or Nano w/ATmega328 or Arduino UNO from menu
5. Click on the Upload icon to begin upload Sketch to Arduino Duemilanove
Now the Arduino Duemilanove is becoming an ISP
1. Connect the Arduino Duemilanove to the computer
2. Open the Arduino software , I'm using arduino-0023
3. Select File> Examples> ArduinoISP from menu as shown in figure
4. Select Tools> Board> Arduino Duemilanove or Nano w/ATmega328 or Arduino UNO from menu
5. Click on the Upload icon to begin upload Sketch to Arduino Duemilanove
Now the Arduino Duemilanove is becoming an ISP
Plugin to Support ATtiny85
1. Download ATtiny85 Plugin
2. Identify the Arduino sketchbook folder, press File> Preferences from menu, figure below shows my sketchbook location in D:\ My Documents\Arduino
3. Make a Hardware sub folder inside the sketchbook folder if it is not exist.
4. Extract the downloaded ATtiny85 Plugin to the Hardware folder as shown in figure below
You will see Tools>Board>ATtiny85 (w / Arduino as ISP) from the menu upon completing of the above procedures.
2. Identify the Arduino sketchbook folder, press File> Preferences from menu, figure below shows my sketchbook location in D:\ My Documents\Arduino
3. Make a Hardware sub folder inside the sketchbook folder if it is not exist.
4. Extract the downloaded ATtiny85 Plugin to the Hardware folder as shown in figure below
You will see Tools>Board>ATtiny85 (w / Arduino as ISP) from the menu upon completing of the above procedures.
Connecting ATtiny85 to Arduino Duemilanove
A 10uF capacitor is connected to Reset and Ground of Arduino Duemilanove to prevent Automatic Reset
Designing a 5 Channel Running Light Circuit
This is a 5 channel running light schematic, five LED is connected to the output of ATtin85, and the 5 resistors is use to limit current flowing through the LED.
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
/ / 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
A More Complicated Sketch
Here is another much more complicated sketch that you can upload to the ATtiny85, it occupied 1508Byte of Flash Memory.
# Define MAX_CHANNEL 5
# 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
int Channel [MAX_CHANNEL] = {CH1, CH2, CH3, CH4, CH5};
long interval = 500; / / speed = 0.5 second
void setup () {
/ / Serial.begin (9600);
for (byte i = 0; i <MAX_CHANNEL; i + +) {
pinMode (Channel [i], OUTPUT); / / declare all channel as output
}
allChannelOn (); / / turn on all LED for one second during startup
delay (1000);
}
void loop ()
{
runDown ();
runKnightRider ();
for (byte i = 0; i <10; i + +) {/ / loop 10 times for random LED
runRandom ();
}
}
/ / / / / / / / / / / / / / / / / / / / / / / / / Turn on all LED
void allChannelOn (void) {
for (byte i = 0; i <MAX_CHANNEL; i + +) {
digitalWrite (Channel [i], HIGH);
}
}
/ / / / / / / / / / / / / / / / / / / / / / / / / Turn off all LED
void allChannelOff (void) {
for (byte i = 0; i <MAX_CHANNEL; i + +) {
digitalWrite (Channel [i], LOW);
}
}
/ / / / / / / / / / / / / / / / / / / / / / / / / Run LED in sequence
void runDown (void) {
for (byte i = 0; i <MAX_CHANNEL; i + +) {
allChannelOff ();
digitalWrite (Channel [i], HIGH);
delay (interval);
}
}
void runKnightRider (void) {
allChannelOff ();
for (byte i = 0; i <MAX_CHANNEL; i + +) {
digitalWrite (Channel [i], HIGH);
delay (interval);
}
for (byte i = 0; i <MAX_CHANNEL; i + +) {
digitalWrite (Channel [i], LOW);
delay (interval);
}
}
/ / / / / / / / / / / / / / / / / / / / / / / / / Run LED randomly
void runRandom (void) {
int allChannelState, previousState, state;
allChannelState = 0;
for (byte i = 0; i <MAX_CHANNEL; i + +) {
state = random (2);
allChannelState = allChannelState + state;
digitalWrite (Channel [i], state);
}
if (allChannelState == 0) {/ / if all LED turned off
/ / Reserved
} Else {
delay (interval);
}
}
# Define MAX_CHANNEL 5
# 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
int Channel [MAX_CHANNEL] = {CH1, CH2, CH3, CH4, CH5};
long interval = 500; / / speed = 0.5 second
void setup () {
/ / Serial.begin (9600);
for (byte i = 0; i <MAX_CHANNEL; i + +) {
pinMode (Channel [i], OUTPUT); / / declare all channel as output
}
allChannelOn (); / / turn on all LED for one second during startup
delay (1000);
}
void loop ()
{
runDown ();
runKnightRider ();
for (byte i = 0; i <10; i + +) {/ / loop 10 times for random LED
runRandom ();
}
}
/ / / / / / / / / / / / / / / / / / / / / / / / / Turn on all LED
void allChannelOn (void) {
for (byte i = 0; i <MAX_CHANNEL; i + +) {
digitalWrite (Channel [i], HIGH);
}
}
/ / / / / / / / / / / / / / / / / / / / / / / / / Turn off all LED
void allChannelOff (void) {
for (byte i = 0; i <MAX_CHANNEL; i + +) {
digitalWrite (Channel [i], LOW);
}
}
/ / / / / / / / / / / / / / / / / / / / / / / / / Run LED in sequence
void runDown (void) {
for (byte i = 0; i <MAX_CHANNEL; i + +) {
allChannelOff ();
digitalWrite (Channel [i], HIGH);
delay (interval);
}
}
void runKnightRider (void) {
allChannelOff ();
for (byte i = 0; i <MAX_CHANNEL; i + +) {
digitalWrite (Channel [i], HIGH);
delay (interval);
}
for (byte i = 0; i <MAX_CHANNEL; i + +) {
digitalWrite (Channel [i], LOW);
delay (interval);
}
}
/ / / / / / / / / / / / / / / / / / / / / / / / / Run LED randomly
void runRandom (void) {
int allChannelState, previousState, state;
allChannelState = 0;
for (byte i = 0; i <MAX_CHANNEL; i + +) {
state = random (2);
allChannelState = allChannelState + state;
digitalWrite (Channel [i], state);
}
if (allChannelState == 0) {/ / if all LED turned off
/ / Reserved
} Else {
delay (interval);
}
}
Tiny Arduino Supported Command
Here is a list of command that supported by Tiny Arduino:
pinMode ()
digitalWrite ()
digitalRead ()
analogRead ()
analogWrite ()
shiftOut ()
pulseIn ()
millis ()
micros ()
delay ()
delayMicroseconds ()
SoftwareSerial (Arduino 1.0 support only)
pinMode ()
digitalWrite ()
digitalRead ()
analogRead ()
analogWrite ()
shiftOut ()
pulseIn ()
millis ()
micros ()
delay ()
delayMicroseconds ()
SoftwareSerial (Arduino 1.0 support only)
My Arduino ISP and Tiny Arduino
My Arduino ISP is very simple too. Figure below shows the connection of my Tiny Arduino and Arduino ISP.
I'm not using an Arduino duemilanove as the Arduino ISP, instead I'm using an ATmega328 MCU burned with UNO bootloader and uploaded with ArduinoISP sketch.
Source: http://ediy.com.my/index.php/blog/item/48-simplest-and-cheapest-arduino
I'm not using an Arduino duemilanove as the Arduino ISP, instead I'm using an ATmega328 MCU burned with UNO bootloader and uploaded with ArduinoISP sketch.
Source: http://ediy.com.my/index.php/blog/item/48-simplest-and-cheapest-arduino