HELLO.BUTTON BOARD
Follow the tutorial Programming Hello Button + LED board
You need:
You need a ISP programerUSBTinny
Get the Software
Download Arduino Software here from Arduino web
Download ATtiny 44 files for Arduino Attiny.zip or download from arduino-tiny.googlecode.com
Download USBTtinny drivers if you need
DATASHEET PINS DESCRIPTIONS
DataSheet here
LOW POWER CONSUMPTION: ATtiny44A are low-power CMOS 8-bit microcontrollers based on the AVR enhanced RISC architecture (Reduced Instruction Set Computer). By executing powerful instructions in a single clock cycle, the ATtiny44A achieves throughputs approaching 1 MIPS (millions Instructions Per Second) per MHz allowing the system designer to optimize power consumption versus processing speed.
FAST AND INDEPENDENT ACCESS: The AVR core combines 32 general purpose working registers. All 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is up to ten times faster than conventional CISC (Complex Instruction Set Computer) microcontrollers.
MEMORY: he ATtiny24A/44A provides the following features: 2K/4K byte of In-System Programmable Flash, 128/256 bytes EEPROM, 128/256 bytes SRAM. It is enought for our project.
The device is manufactured using Atmel’s high density non-volatile memory technology. The onchip ISP Flash allows the Program memory to be re-programmed in-system through an SPI serial interface, by a conventional non-volatile memory programmer or by an on-chip boot code running on the AVR core.
PINS DESCRIPTIONS
VCC: Supply voltage.
GND: Ground.
PORT B (PB3:PB0): Port B is a 4-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability except PB3 which has the RESET capability. To use pin PB3 as an I/O pin, instead of RESET pin, program (‘0’) RSTDISBL fuse. As inputs, Port B pins that are externally pulled low
will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running.
RESET: Reset input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running and provided the reset pin has not been disabled. The minimum pulse length is given. Shorter pulses are not guaranteed to generate a reset. The reset pin can also be used as a (weak) I/O pin.
PORT A (PA7:PA0): Port A is a 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port A output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port A pins that are externally pulled low will source current if the pull-up resistors are activated. The Port A pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port A has alternate functions as analog inputs for the ADC, analog comparator, timer/counter, SPI and pin change interrupt.
Attinny pins equivalence for programming in Arduino
PROGRAMMING ATTINY44
You need two important steps here
1. Install Attiny folder
Go to Sketchbook folder in Arduino (Menu Preferences) and create a folder named hardware.
Unzipped and copy Attiny folder from Attiny.zip in hardware folder.
2. Install Attiny Board
Go to Sketchbook folder in Arduino (Menu Preferences) and copy this direction: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
Goto Tools/Board/Board Manager and install Attiny boards
Restart the Arduino program
Power Conections
Connect LED + Button board to programmer (USBtinny)
Conect MISO, MOSI, SCK, RESET, VCC and GND pins from programmer to LED + Button board correctly
Conect LED + Button board with FTDI cable. You can do from usb cable used and take GND and VCC wires
CONFIGURATIONS
Select Attiny44 board
Select Attinny44 processor
Select Clock (20 Mhz)
Select USBTtinnyISP Programmer
Burn Bootloader
Bootloader burns the Attinny44 fuses for 20 Mhz Clock.
Fuses burns only one time in micro.
Use Upload for program in Hello board
You see "Done Uploading" without errors
ARDUINO CODE
int led_red = 7; //Define Variables
int led_green = 8;
int button = 3;
char cont = 0; // Counter
In this part, we define variables, integers and charactes. Int led_red = 7
we call "led_red", "led_green" and "button" as integer (2 bytes or 16 bits). We use "cont" as character (1 byte) because I need only 5 times to count.
void setup()
{
pinMode(led_red, OUTPUT); //Pins mode I/O
pinMode(led_green, OUTPUT);
pinMode(button, INPUT);
}
The void setup()
function is called when a sketch starts. Used it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board.
In this case, I called "led_red" and "led_green" as OUTPUT mode, and "button" as INPUT mode.
void loop()
{
if (digitalRead(button) == 0) //When button is pushed, count how many time is pushed
{
if (cont < 5)
{
cont++; //increment count
}
else
{
cont = 0; //When count is 5, "else" resets to 0 and start it again
}
}
switch (cont) //Jump to case with "cont" value
{
case 1: //When you push 1 times
digitalWrite(led_red, HIGH);
digitalWrite(led_green, HIGH);
break;
case 2: //When you push 2 times
digitalWrite(led_red, HIGH);
delay(100); //Time waiting 100 ms
digitalWrite(led_green, HIGH); //Led green ON
delay(100);
digitalWrite(led_red, LOW); //Led red OFF
delay(100);
digitalWrite(led_green, LOW); //Led green OFF
delay(100);
break;
case 3: //When you push 3 times
digitalWrite(led_red, HIGH);
digitalWrite(led_green, HIGH);
delay(100);
digitalWrite(led_red, LOW);
digitalWrite(led_green, LOW);
delay(100);
break;
case 4: //When you push 4 times
digitalWrite(led_red, HIGH);
delay(100);
digitalWrite(led_red, LOW);
delay(100);
break;
case 5: //When you push 5 times
digitalWrite(led_green, HIGH);
delay(100);
digitalWrite(led_green, LOW);
delay(100);
break;
default: // State when system starts
digitalWrite(led_red, LOW);
digitalWrite(led_green, LOW);
break;
}
}
PROTEUS CODE SIMULATION
VIDEO
DOWNLOAD FILES
All files Download