Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Table of Contents
Step 1: Supplies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
http://www.instructables.com/id/Apple-style-LED-pulsing-using-a-130-MCU/
Author:hardwarehank Schadenfreude
Just a dude who reads a lot of Instructables.
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 (!!!).
Step 1: Supplies
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
File Downloads
Download it and go to section 11 and just take 30 minutes and read the entire thing. Trust me, it's worth it - it's a lot better than randomly paging through it for hours trying
to debug your code! :P
File Downloads
Atmel.ATTiny.25.45.85.Datasheet.pdf (4 MB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Atmel.ATTiny.25.45.85.Datasheet.pdf']
http://www.instructables.com/id/Apple-style-LED-pulsing-using-a-130-MCU/
Step 4: Bread it up, homie
Let's do some breaddage. I've attached a picture, but the rest is up to you, young padawan. Read the datasheet pinout and the pinout of your programmer and get that
mojo workin'. There's like a million guides on how to do this, so do your homework. This is a skill you should have - datasheets are the bomb, yo .
int main()
{
// Turn on LED output pin
DDRB |= _BV(DDB0);
Hopefully, this code is self-documenting. Basically, we're changing the pulse width every few hundred clocks in one direction or the other. We have a special case for
when we get to the top or bottom (change direction and linger), just like the Apple stuff does. There's another special case when we want to completely turn off the LED at
the bottom - if we don't do this, it still has a (1/256)% duty cycle, and you can see it. Otherwise, the code should be rather concise. Constructive criticism encouraged.
http://www.instructables.com/id/Apple-style-LED-pulsing-using-a-130-MCU/
Step 6: The result
Here's a short video of the result. I'm pretty happy with it. Get some of the chips and go to town!
Related Instructables
Simplest and
Cheapest
Turn Your Arduino by
Arduino Into an smching Self-contained ATTiny85 Traffic Program an ATtiny
ISP by mr_mac3 16-Digit display Light by ATtiny with programming
- Arduino & nthdesign Arduino by with Arduino by
Attiny85 by randofo wirenut1980
Panici
Advertisements
Comments
6 comments Add Comment
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...."
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?
http://www.instructables.com/id/Apple-style-LED-pulsing-using-a-130-MCU/
hardwarehank says: Mar 3, 2011. 6:11 AM REPLY
Thanks :).
It is definitely doable for someone inexperienced with microcontrollers who is just getting comfortable with the AVR platform. It could definitely be
adapted to an ATmega - the only changes would be register naming I think. Just find the equivalent PWM registers in your datasheet and everything
should work fine :).
Oh, and AFAIK, sketch refers to an Arduino program written in Processing. This is a program. It's fo' real, yo!
In Arduino, sketch refers to ANY program. They are called "sketches" to keep artsie folks from getting scared by the name.
Now use digital pin 6 for your LED (with a current limiting resistor in series to ground)
Seeing how TCCR0B is not assigned, the comment should read as follows per the datasheet:
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:
Please advise,
Moe Howard (brother of Shemp)
http://www.instructables.com/id/Apple-style-LED-pulsing-using-a-130-MCU/