Introduction: How to Program an ATtiny85 Using Arduino - Como Programar Um ATtiny85 Usando Arduino

How to easly shrink simple projects?

Como diminuir seus projetos mais simples?

ATtiny85 is a simple to use, cheap and small (8 legs) microcontroller. You can program it with any Arduino and can use the Arduino IDE itself to write and upload your code to it (with minor installation procedure).

ATtiny85 é um microcontrolador simples, barato e pequeno (8 pernas). Você pode programá-lo com qualquer Arduino e pode usar a própria IDE do Arduino para escrever e subir o código para ele (com pouca instalação).

Step 1: List of Materials - Lista De Materiais

Recommended: download the last version of Arduino IDE.

Recomendável baixar a última versão da IDE Arduino.

Step 2: Arduino As ISP - Arduino Como Um ISP

ISP - "In-System Programming" (programação "no sistema")

Upload to your Arduino board the "Arduino ISP" sketch present on IDE's "Examples".

Carregue para sua placa Arduino o código "Arduino ISP" presente nos Exemplos da IDE.

Step 3: Customize Your Arduino IDE to Know ATtiny85 - Faça Sua IDE Arduino Saber Do ATtiny85

Download:

Arduino 1.6.4

(not yet tested - não testado) as for http://highlowtech.org/?p=1695 reference:

"You can install the ATtiny support using the built-in boards manager. Open the preferences dialog in the Arduino software. Find the “Additional Boards Manager URLs” field near the bottom of the dialog. Paste the following URL into the field (use a comma to separate it from any URLs you’ve already added):

https://raw.githubusercontent.com/damellis/attiny/...

Click the OK button to save your updated preferences. Open the boards manager in the “Tools > Board” menu. Scroll to the bottom of the list; you should see an entry for “ATtiny”.Click on the ATtiny entry. An install button should appear. Click the install button. The word “installed” should now appear next to the title of the ATtiny entry. Close the boards manager. You should now see an entry for ATtiny in the “Tools > Board” menu."

Arduino 1.6

ide-1.6.x.zip

Arduino 1.0

ide-1.0.x.zip

Installation:

  1. close Arduino enviroment - feche o programa
  2. unpack the "attiny" subfolder - desempacote o subdiretório "attiny"
  3. ... to "hardware" folder on Arduino base installation (create one if absent) - para o diretório "hardware" no diretório de instalação da IDE (crie um se ausente)
  4. open IDE and find the boards on the menu - abra a IDE e veja as placas em:

Documents > Arduino > hardware > attiny > avr

Step 4: Choose Speed - Escolha a Velocidade

Before start making uploads you have to chose it's frequency and source of clocking.

Antes de começar a fazer uploads você deve escolher a frequência e a origem do clock.

(Default: 1 MHz (Internal).)

  1. find and select your settings from the Tools > Clock menu (e.g. “8 MHz (Internal)”)
    • (in Arduino 1.0.x, select the appropriate 8 MHz clock option from the main Tools > Board menu)
    • if you chose "external" you have to conncet an external clock to your µC
  2. run the “Burn Bootloader” command from the Tools menu.
    • this configures the fuse bits of the µC
    • this doesn’t actually burn a bootloader onto the chip (you’ll still need to upload new programs using an external programmer)
    • you only have to do this again if you need to change this parameters
  1. encontre e seleciona as configurações em Ferramentas > Clock (e.g. “8 MHz (Internal)”)
    • (no Arduino 1.0.x, selecione a opção em Ferramentas > Placa)
    • se você escolher "externo" você deverá conectar um clock externo em seu µC
  2. rode “Burn Bootloader” (grava Bootloader) no menu Ferramentas
    • isso configura os bits de fuso do µC
    • isso não grava realmente um bootloader no chip (você ainda precisa de um programador externo para carregar seus programas)
    • você só precisa fazer isso novamente caso precise mudar esses parâmetros

Step 5: Hello/Blink World!

Take a look at the datasheet:

http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-M...

The pinout of the Attiny85 is on this picture, it should be simple to use it as easly as an Arduino board.

A pinagem do ATTiny85 é mostrada na figura, usá-lo deve ser tão simples como uma placa Arduino.

  1. open Blink example - abra o exemplo Blink
  2. (as ATTiny85 doesn't have 13 i/o pins...) change pin number from 13 to 0 - mude o pino 13 para 0
  3. select ATtiny from the Boards menu - selecione ATtiny no menu placas
  4. select "Arduino as ISP" on the Tools > Programmer menu - selecione "Arduino como ISP" no menu Ferramentas > Programador
    • or another apropriate item if you are using another programmer - ou o item apropriado se você está usando outro programador
  5. connect your Arduino (previously programmed as an ISP) to your ATtiny85 - conecte seu Arduino (programado como um ISP) no seu ATtiny85:
  6. upload!
  7. do your LED circuit - faça seu circuito de LED

Step 6: Program!

The following Arduino commands should be supported:

Os seguintes comandos de Arduino são possíveis:

  • pinMode()
  • digitalWrite()
  • digitalRead()
  • analogRead()
  • analogWrite()
  • shiftOut()
  • pulseIn()
  • millis()
  • micros()
  • delay()
  • delayMicroseconds()
  • SoftwareSerial (updated in Arduino 1.0)

Attention! Altough ATtiny85 has a nice harware interface (USI - Universal Serial Interface), it doesn't support (hardware) Serial communication and naturally neither its Arduino library. If you need, consider SoftwareSerial.

Atenção! Apesar de que o ATtiny85 possui uma boa interface (USI - Universal Serial Interface), ele não suporta comunicação Serial (por hardware) e naturalmente também não a sua biblioteca de Arduino. Se for preciso, considere SoftwareSerial.

Step 7: Use!

Some projects:

http://hackaday.com/?s=attiny85

https://www.instructables.com/howto/attiny85/

My references:

http://labdegaragem.com/profiles/blogs/tutorial-pr...

http://highlowtech.org/?p=1695

My crew:

aelastica.org

fb.com/aelastica

https://groups.google.com/forum/#!forum/amola

* Este material também será impresso na forma de zine para a primeira Zine Elástica!