Glowing "alien's Heart"
I found this creepy silicone ball that had lost all air pressure from a second hand store toy bin. The alien look and red colour made me think about a heartbeat ... heartbeat of light...
So I tried out programming Attiny45 with Arduino as I had both already in my drawer. How to do that (or ATtiny85) you can read from MIT original article or an instructable by randofo.
It is just an uneven fade in and out script.
The ATtiny has three inputs and another PWM pin unused and there is plenty of room on the stripboard so I might add something to it in the future. For example a sensor, a shake could make it "beat" faster.
I chose a 3V lithium battery with highest amphours available as most of them had same prize. That happened to be CR2430 that is pretty large sized. Attiny works on voltages between 2.7 and 5.5 so the 3V is perfect. Battery holder and switch are totally improvised.
The battery holder: I arranged ATtiny's ground pin and LED's ground pin to strips on the stripboard that are relatively centered. Then I soldered a wire (a cut off component leg) bent into a U-shape through holes in these ground rails. Then I pierced a piece of cardboard with the ends of the U and bent the ends down - the cardboard isolates battery ground from the rest of the stripboard, only the two pierced wire ends make contact. Then I bent a longer thin wire to fit over the battery and soldered its ends to the corners of stripboard. The battery stayed under it pretty well, but additionally I secured it with a rubberband.
The switch is a simple loose end of stranded wire, stripped, tinned and made sturdier with heatshrink tubing, that can be tucked between the battery and it's holding wire. For some reason there were no small cheap switches in store, so I saved some money and room with that.
The ATtiny code:
So I tried out programming Attiny45 with Arduino as I had both already in my drawer. How to do that (or ATtiny85) you can read from MIT original article or an instructable by randofo.
It is just an uneven fade in and out script.
The ATtiny has three inputs and another PWM pin unused and there is plenty of room on the stripboard so I might add something to it in the future. For example a sensor, a shake could make it "beat" faster.
I chose a 3V lithium battery with highest amphours available as most of them had same prize. That happened to be CR2430 that is pretty large sized. Attiny works on voltages between 2.7 and 5.5 so the 3V is perfect. Battery holder and switch are totally improvised.
The battery holder: I arranged ATtiny's ground pin and LED's ground pin to strips on the stripboard that are relatively centered. Then I soldered a wire (a cut off component leg) bent into a U-shape through holes in these ground rails. Then I pierced a piece of cardboard with the ends of the U and bent the ends down - the cardboard isolates battery ground from the rest of the stripboard, only the two pierced wire ends make contact. Then I bent a longer thin wire to fit over the battery and soldered its ends to the corners of stripboard. The battery stayed under it pretty well, but additionally I secured it with a rubberband.
The switch is a simple loose end of stranded wire, stripped, tinned and made sturdier with heatshrink tubing, that can be tucked between the battery and it's holding wire. For some reason there were no small cheap switches in store, so I saved some money and room with that.
The ATtiny code:
/* "Alien's heart" for Attiny45 (or 85). Derived largely from "Fade" sketch. by liba_hunt */ int brightness = 0; // variable for current LED brightness const int fadeAmount = 5; // brightness change step size boolean middlebeat = true; //variable to indicate if a quicker fade-in-out should be done next int del = 40; //variable for delay time between change of brightness void setup() { pinMode(0, OUTPUT); //ATtiny45 (or 85) has pins 0 and 1 for PWM (analogWrite) } void loop() { analogWrite(0, brightness); //LED on a current brightness brightness = brightness + fadeAmount; //set next brightness level if (brightness == 255) { fadeAmount = -fadeAmount;//reverse direction of brightness change if (middlebeat == true) {//if quicker fade-off phase starting del = 2; //set delay shorter } else {//if slower fade-off phase starting del = 40; //set delay longer } } if (brightness == 0) { fadeAmount = -fadeAmount;//reverse direction of brightness change if (middlebeat == true) { //if in the middle of quicker fade-on phase middlebeat = false; //set middlebeat to false to indicate it's done } else { //if in the middle of slower fade-on phase middlebeat = true; //set middlebeat to true to indicate the quicker phase has to start next } } delay(del);//delay between change of LED brightness }