3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Apple-style LED pulsing using a $1.30 MCU

Apple-style LED pulsing using a $1.30 MCU
The Atmel ATTiny85 chip is an 8-pin MCU that is totally awesome.  If you've been programming with the bigger boys (the ATMega series), these are a nice adventure - you're rather limited in the number of output pins, but a creative design gives us a lot of flexibility in a very small package.

You've seen them - those "Apple computers."  Probably in the hands of some Hipster in Portland, while riding his fixie and wearing those thick framed glasses.  That pulsating light when Apple laptops are asleep is so ... sooooothing.  You just want to go to sleep watching it.  You know you do.

Today, we're going to replicate that using our ATTiny85.  It's really easy, and most of it can be implemented in hardware instead of code (!!!).
 
Remove these adsRemove these ads by Signing Up
 

Step 1Supplies

  1. Breadboard
  2. Breadboard wires
  3. 1 LED
  4. ATTiny85 (the 45 or 25 will probably work, but I haven't tested them)
  5. An ISP programmer (or other, if you know how to use it) - I use the USBtinyISP.
  6. A computer with avrdude and avr-gcc
  7. Optional: an oscilloscope
« Previous StepDownload PDFView All StepsNext Step »
6 comments
Mar 19, 2012. 2:31 AMM.Hawse says:
Thank you HardwareHank for taking the time to post this jewel! Thanks also to jdelongpre & average_male for the Arduino conversion info!

I'm diving back into 'lectronics* prototyping again after a 5 year break. I just got an Arduino Mega R3 and am loving it. 

This is a cool project that's looks easy to complete because it's well documented with plenty of tips and suggestions.  Great job...you've made it easier and fun for the rest of us.

*NOTE: 'lectronics - This is a term usually heard only in the US Southern States.  Usually, it's being shouted over a 2W loudspeaker system in Walmart: " ... 'lectronics, Line 1...."
Mar 2, 2011. 6:01 PMDodge says:
Nice effect! I like it. *favorited*

I'm just getting started with microcontrollers, and projects like this seem doable for a noob.

With some tweaking, this sketch would work on an Atmega chip as well, right?
Oct 16, 2011. 2:23 PMjdelongpre says:

In Arduino, sketch refers to ANY program. They are called "sketches" to keep artsie folks from getting scared by the name.

To run this on an Arduino, you must change just one line:
    DDRB |= _BV(DDB0); // for Attiny85 OC0A=PB0 (comment added)
-- to--:
    DDRD |= _BV(DDB6); // for Arduino OC0A=PD6
-- or-- in the language of a sketch:
    pinMode(6, OUTPUT); // enable OC0a output
The two forms do exactly the same thing and either works.

Now use digital pin 6 for your LED (with a current limiting resistor in series to ground)
Jun 17, 2011. 4:41 PMaverage_male says:
Is the comment still correct for the Fast PWM when the code has the assignment of the "TCCR0B" register commented out?

// Use Fast PWM, OCRA TOP
TCCR0A |= _BV(WGM00);
TCCR0A |= _BV(WGM01);
//TCCR0B |= _BV(WGM02);

Seeing how TCCR0B is not assigned, the comment should read as follows per the datasheet:

// Use Fast PWM, OCR0A = 0xFF
TCCR0A |= _BV(WGM00);
TCCR0A |= _BV(WGM01);

Or does that matter as your code happens to assign 0xFF (255) to OCR0A via the following line and then later have a check for this value elsewhere in the code:

// General case - increment direction either way
OCR0A += dir;

Please advise,
Moe Howard (brother of Shemp)

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
13
Followers
8
Author:hardwarehank(Schadenfreude)
Just a dude who reads a lot of Instructables.