Instructables

Throwduino Basic - Light-Sensing Flashing Throwie with 1 Added Part - Now with Morse Code

FeaturedContest Winner
Picture of Throwduino Basic - Light-Sensing Flashing Throwie with 1 Added Part - Now with Morse Code
Throwies are great.  They have a minimal parts count - 2 or 3 depending on whether you use a magnet - and produce a great effect.  They are very cheap and easy but not highly efficient:

1)  They are on all the time, so on average they waste half of their energy shining during the day.

2)  A continuous light is not as visible as a flashing light. An interesting flash-pattern adds to the intrigue and can even convey information.

3) Their Duty cycle is too high - a duty cycle of 10-20% is more than sufficient to be both visible and much more efficient. 

This is the first of what I hope to be 2-3 versions of microcontroller projects designed to be so cheap that they can be used as throwies.  The plan is to make them more efficient and use that gain to provide a more exciting effect.

This is the "basic" version - it requires only one additional part, three blobs of solder and a few snips.  And by magic* it can address all of the issues above.  It's programmable using the Arduino IDE, hence "Throwduino".

On a per-hour basis it should even work out cheaper than a normal throwie.  The cost analysis is in step 5.

Edit - Morse Code sketch now available - see last step.
        - Now you can throw your own message of choice!


* not actually magic - see step 6.
 
Remove these adsRemove these ads by Signing Up
ljohann made it!5 months ago

Just a quick note that I had to change the battery in my Morse Egg which is based on the Throwduino but includes a 220 Ohm resistor connected to the LED. That results in 85 days using a single battery.

InsideEgg.jpg
Ugifer (author)  ljohann5 months ago

Hi Lars - thanks for your comment and picture! Always great to see a project made - I'll send you a 3-month pro by PM.

I guess the 220R just cuts down the current that bit more - 85 days is pretty impressive on a singe cell. And it looks like you used a CR2025, which is lower capacity than the 2032 as well!

Love that the light sensing still works too. When the pin is set to input it should be "high resistance" - drawing minimal current so the resistor should not matter. However it's always great to see what happens in practice. There's usually more going on with these things than I understand at least!

Cheers

Ugi

ljohann8 months ago

Great tutorial! I soldered mine on a prototype PCB along with a battery holder in a candybox container. When the battery is empty I can easily revive it (if it still sits where I placed it). I also included a 220 Ohm resistor (don't know if this will increase battery time or not). I was curious whether or not the resistor would affect the sensing function, but it works just fine!

Best wishes,

Lars

SurpriseMorseEgg.jpgInsideEgg.jpg
You ppl may like to see my Light sensor LED, using only a resistor and an LDR... ;-D

reg
k
-------------------------------------------------------
"May the good belong to all the people in the world.
May the rulers go by the path of justice.
May the best of men and their source always prove to be a blessing.
May all the world rejoice in happiness.
May rain come in time and plentifulness be on Earth.
May this world be free from suffering and the noble ones be free from fears"
---- Vedic blessing


Lord_Vek2 years ago
Good instructable good use of Arduino, Attiny and the trick to use the LED to measure the light.
I made one Throwduino to see how it works, with the Morse code. I initialized it (connected the battery) in absolute darkness, so it would light only in darkness. But it works continuously, no matter if it is darkness or light. Am I doing anything wrong ?
Also, in the first program:

const byte flashSeq[3]={1,4,3}; // Flash pattern. Edit this.

// If you just want a longer pause, use 0 for each 500ms.

what do you mean by that ? Make an example please. I tried first this code, with 4,4,4, as flashSeq parameters but I got 12 flashes because I didn't knew how to make longer pauses.

Thanks in advance.
Ugifer (author)  Lord_Vek2 years ago
Hi - thanks for your message and for your interest in the project. I haven't met these issues with it before but I will help as much as I can.

I assume by "works continuously" you mean that it flashes the whole time, rather than the light is on continuously. If the latter then it's probably a hardware issue (did you clip the wire between the pins for example?).

The LED light sensing has worked with all the white, blue and blue/green LEDs that I have tested. That does not mean there are no LEDs that won't work but I would be surprised. What LED are you using? Colour? Vf? clear or diffused? It shouldn't matter but I'm just interested.

Are you using the same chip (ATTiny 85) and battery (CR2032)? Do you have all the connections made correctly? I'm happy to look at a picture of your device if you post it (or PM me) to see whether I can spot any issues.

You should not need total darkness but you do need to remember that it senses over 40 seconds, so you have to wait that long before bringing it out into bright light. The first 10 seconds are not used, so you can connect the battery in the light then put it in your cupped hands within the first few seconds and that should be easily enough.

My guess would be that the battery connection broke briefly after you brought it out into the light so it re-sensed in the daylight. Maybe try connecting & tape it up well in the light so you can see what you are doing and then putting it under an upturned coffee cup for a minute after. It takes an average so even if your first few seconds are in day light, some time in darkness will push the average down enough.

With the original sketch, the LED will flash a few times after the sensing phase to tell you what value it has sensed. Might be worth looking at that. If you connect the battery in bright light it should flash out a higher reading than in low light (obviously) so try under both conditions and check that it's measuring the difference.

With regard to the flash sequence, {4,4,4} should give you three groups of four flashes, with a short pause between each group. If you do {4,0,4,0,4} then you should get longer pauses between groups. If you do {1,0,0,0,2,3,0,0,4} then you get: flash, long wait, flash, flash, short wait, flash, flash, flash, fairly long wait, flash, flash, flash, flash.

Hope that's of some help. If you can supply more details I will try to help further.

Cheers

Ugi
Ugifer (author)  Ugifer2 years ago
PS I think I may have made a mistake in the code!

It has worked fine for me, but I think this line:

threshold=(total>>5); // set threshold to average point (divide total by 128).

Should be:

threshold=(total>>7); // set threshold to average point (divide total by 128).

I can't check it just now - I'm at work - but try that and see if it helps.

Ugi
Lord_Vek Ugifer2 years ago
Update...

Then I saw the PS for the threshold, I made the changes and it now works like a charm!!!

Light / Dark detection - OK.

Pauses - OK.

Thank you very much for the answers and for the nice instructable! Be well!
Ugifer (author)  Lord_Vek2 years ago
Thank you for taking the time to comment - I would not have found the bug without that, because mine have worked so far - must be a difference in the performance of the LEDs.

I'll make a correction to the 'ible.

Cheers

Ugi

PS watch out for the RGB version, which will hopefully hit instructables pretty soon!
Lord_Vek Ugifer2 years ago
Glad to help. I like very much these easy to make, yet sophisticated and clever instructables like yours. I had my Arduino ready with ISP program into it and a breadboard ready to put an ATtiny, so it only took a quarter of minutes to make the changes, reprogram and test. I also made a PCB, since I didn't want to cut the Attiny pins (and in case something went wrong), but also to be able to put the circuit into a plush toy or something. I 'll try to post it.
One thought I made, with a little more code and a mobile vibration motor, you could have something buzzing into a drawer when it's closed (dark) but idle when someone opens it to look into. I read this in High tech practical jokes for the Evil Genius. Thanks again.
Here they are. The .zip contain the eagle files. You can connect either piranha, or normal Led.
Attiny Throwduino.png
3V Battery connector at the back side, that;s why it is so big.
Lord_Vek Ugifer2 years ago
I believe the circuit I made is correct, otherwise the Led wouldn't lit, or it wouldn't work at all.
Thanks for the answer. I am using a clear red Led, I also tried with a clear blue, and a green piranha. I don't know Vf for any of them. I will try again, based on your above answer for the initial seconds, and also I will try the pauses with the first code.

Thanks for the answer, my friend.
Hi Ugifer,

This great demonstration on how simple and cheap an ATtiny circuit can be, was an inspiration for my newest Ible: A(T)tiny StarBird.

Thanks!
Ugifer (author)  masynmachien2 years ago
That's fantastic - I love the project and it's always great to know that something you did helped to spark an idea with someone else.

Thanks for your kind comments.
Great!
you got my vote
Ugifer (author)  masynmachien2 years ago
Thank you - much appreciated!
ynze2 years ago
Nice idea! Would it be cheaper (and maybe easier) to use a 555 timer ic in a PWM-circuit to power the LED, instead of a microcontroller?

A pwm circuit needs a bit more parts than your solution, I expect... Did you consider using a 555?
Ugifer (author)  ynze2 years ago
I came at it rather from the opposite direction - more along the lines of:

"Hey! You can get an ATtiny for 50p! They could be disposable at that price - let's do something fun and not worry about losing the chip"

You could use a 555 for a flashing circuit or a PWM "heatbeat" but I have a feeling they are pretty power-hungry and they don't "sleep" like the AVR does. For this project, whenever the light is off the ATTiny is asleep drawing 4.5 microamps! I don't think you would get the same kind of lifetime out of a 555. Would be fun to see thou'.
Ugifer (author)  Ugifer2 years ago
Oh, and you wouldn't get the dark-detecting effect either without a load more components. The great thing about this is that the ATTiny can read the light level, control a meaningful pulse sequence and use only a vanishing current when it's not active.
ynze Ugifer2 years ago
You're right 100%! The 555 _is_ power hungry. I'm not very much into microcontrollers, that's why I first thought of the 555. ATTiny seems the very best choice to do this.
blhack2 years ago
Oh, and sorry for rapid-commenting (but I think this is awesome!)

Soldering things directly to the chip like that is called a "dead bug" configuration.

Maybe that's totally common knowledge, and I'm a dork for not know it, but I laughed hysterically when I heard it A guy at our lab recently was talking to me about an attiny project I was working on and was like "oh, you could deadbug it!"

Me: "Deadbug...uhhwhat?"

Him: "Deadbug!"

And he pulls out a chip with a bunch of components soldered to the bottom.

Him: "See, it looks like a dead bug!"

:)
Ugifer (author)  blhack2 years ago
Yeah - and this one is a poor dead bug with most of its legs pulled off! ;-)
blhack2 years ago
If you want to do this instructable, and don't have a programmer, check out this awesome project out of MIT's fab lab:

http://fab.cba.mit.edu/content/projects/fabisp/

(It's a programmer built on an attiny44 and some passive components. Totally awesome!)

Also check out THIS project:

http://hlt.media.mit.edu/?p=1229

Which lets you program your attiny directly from your arduino! You don't even need to solder anything. TOTALLY AWESOME!
Ugifer (author)  blhack2 years ago
You are right - I had meant to link to a couple of breadboard programming methods. I'll edit in the morning to link some.
blhack2 years ago
YEESH! These would be expensive! Do you have an ultra-cheap source on attinys?

(Because if you do, you should share it with your new best friend, blhack)
Ugifer (author)  blhack2 years ago
60p from Mouser is not too expensive for an Attiny, when a throwie costs about that (if you include a magnet). They make up in extended lifetime what they cost in extra investment! The issue for a UK order is the delivery charge but they drop that on orders over £50.

Current cheapest DIP ATTiny45 from Mouser is 43p + VAT (8p) = 51p if you buy 10 or more.
dombeef2 years ago
Couldn't you technically make them pulse like Apple computers when they sleep? I would think the AVR is powerful enough
blhack dombeef2 years ago
Yes, you can. The attiny85 can do PWM.

Source: I have done literally that (emulating my mac's light, ha)
Ugifer (author)  dombeef2 years ago
You could do that easily - and with the same hardware I think (PB4 can handle PWM AFAIK) - but I think you would have to keep the AVR awake to do it and that takes several mA overhead. However, if you did a heartbeat then slept for a couple of seconds before the next, you could get a fair lifetime.