Code Monkey home page Code Monkey logo

attiny85-hello-world's Introduction

ATTiny85 Hello World

Blinking an LED using an ATTiny85 programmed with avr-gcc and avrdude on Mac OS X.

Mac OS X AVR toolchain install

Using Homebrew, tap larsimmisch's homebrew-avr repository:

brew tap larsimmisch/avr
brew install avr-libc

Build steps

  1. Compile with avr-gcc
  2. Prepare the hex file with avr-objcopy
  3. Flash the hex with avrdude
avr-gcc -Wall -Os -DF_CPU=1000000 -mmcu=attiny85 -o hello.o hello.c
avr-objcopy -j .text -j .data -O ihex hello.o hello.hex
avrdude -c usbtiny -p t85 -U flash:w:hello.hex:i

F_CPU must be defined at the avr-gcc command line or above the #include <util/delay.h> so the delay library knows the microcontroller's clock speed.

Breadboard configuration

Wire the ISP-6 cable from the USBTinyISP to the breadboarded ATTiny85 using jumpers.

ISP-6 pinout

Looking at the ISP-6 cable with the connector key at the bottom, the pins are numbered like this:

+-----------+
|(6) (4) (2)|
|(5) (3) (1)|
+-----------+
     |_|
  1. MISO
  2. Vcc
  3. SCK
  4. MOSI
  5. Reset
  6. Ground

(See also this photo)

ATTiny85 pintout

The ATTiny85's pins are:

 (8) (7) (6) (5)
+---------------+
|               |
| o             |
+---------------+
 (1) (2) (3) (4)
  1. PB5 (Reset)
  2. PB3
  3. PB4
  4. Ground
  5. PB0 (MOSI)
  6. PB1 (MISO)
  7. PB2 (SCK)
  8. Vcc

Programming jumpers

Connect the ISP and the ATTiny85 together on the Ground, MISO (Master In, Slave Out), MOSI (Master Out, Slave In), SCK (Serial ClocK), Reset, and Vcc pins:

  • ISP-6 pin 1–ATTiny85 pin 6 (MISO)
  • ISP-6 pin 2–ATTiny85 pin 8 (Vcc)
  • ISP-6 pin 3–ATTiny85 pin 7 (SCK)
  • ISP-6 pin 4–ATTiny85 pin 5 (MOSI)
  • ISP-6 pin 5–ATTiny85 pin 1 (Reset)
  • ISP-6 pin 6–ATTiny85 pin 4 (Ground)

N.B. The ATTiny's pins 2 and 3 are unconnected.

LED circuit

Power the LED with a transistor and a series resistor, switching the transistor using a resistor from the ATTiny's pin 2 to the transistor's base.

References

attiny85-hello-world's People

Contributors

casebeer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.