Introduction: Arduino Decision Box. (Attiny85)

Picture of Arduino Decision Box. (Attiny85)

So I was a bit bored this weekend (actually I wrote this some months ago) and since I had ordered a bunch of Attiny85 chips the week after I decided to make a quite random project with them.

This is a decision box, it takes decisions for you by showing a green or a red light (it can also show orange if we programmed it to combine both colors). It's made from wood and it has an aluminum plate to cover it all, I painted black because small wood objects tend to get quite dirty.

If you want to build one you'll need the following materials:

  • Wood (my final box is (3x3x3) cm)
  • Red/green led with common cathode (negative leg at the middle)
  • A pushbutton (you might want to get one long enough)
  • Aluminum plate. (3x3x~0.1) cm
  • 4x small wood screws.
  • Thermofusible glue
  • Attiny85
  • 3V button cell.
  • 100, 500 and 10000Ω resistors.
  • 8pin chip socket (if you plan to reuse the attiny)
  • Tilt switch (optional but highly recommended)
  • Thin wires (preferably non solid core)

These tools are also recommended:

  • Dremel (performs better in this kind of tasks than a simple drill)
  • A saw (jewelers saw) is needed if you plan to cut the wood cube and aluminum lid by yourself.
  • Sandpaper (when it comes to making a perfect square there's nothing like sandpaper)

Step 1: Making the Body

Picture of Making the Body

Cut the wood cube, you can also use pre cut slats, this can save you a lot of time.

As always make the marks with the ruler and start to cut, unless you have very precise saws like a bandsaw or a circular wood saw the chances are you make the cube a bit irregular, this is were the painful method of measuring and sanding comes to play, mark the places you want to sand with a pencil and sand them placing the sandpaper over a flat surface.

If all goes well it should look like the picture.

Step 2: Hollowing It

Picture of Hollowing It

Now you have make an empty space inside it, this operation is quite delicate and should be made with care.

What I did was to place the cube at my table clamp using a rag, so it doesn't leaves marks on it, then with the Dremel I used a normal drill bit to make the initial holes, it's very useful to put a bit of tape on the bit to avoid drilling through all the piece.

Once I have a bunch of small holes, I used the carving bit of the Dremel to carve a nice hole, finally with the sandpaper bit I smoothed the walls.

A 0,4 - 0,3 mm wall thickness is recommended.

IMPORTANT: leave more space on the corners where the screws will be placed, this grants you a bigger margin of error.

Step 3: Accomodate the Components

Picture of Accomodate the Components

Once you have a nice empty space where you can allocate your components you can make the holes for the push button and the LED , at this point you have two main options:

a) Drill the holes in the wood.

b) Drill the holes in the aluminum plate.

If I had the chance do this again I might make the holes at the aluminum plate because the pushbutton becomes easier to install since the thickness of the wood makes you have to use a long button, also when you unscrew it the whole thing comes out, if you do it the other way the components have to be stick to the wood and this might be quite annoying. The problem of attaching the components to the aluminum plate is the thermofusible glue doesn't sticks to metals too well and it could end flimsy.

As always mark the right spot and have a firm hand.

Step 4: The Lid

Picture of The Lid

The aluminum plate is easy to cut off, just grab the box and with a pencil mark the outlines of the bottom of it, then with care, cut it out with a jeweler's saw, you can later sand the corners and edges so they end smoother.

TIP: because the bottom of the box is probably going to be a bit irregular is useful to make a mark at the same corners of the box and plate so you can later align them correctly.

To make the holes get an appropriate bit and mark the points where you have to drill by making lines 3mm away from the sides of the plate.

TIP: to make sure the bit doesn't moves and scrapes the metal you can punch a little hole with a pointy screw and a hammer, that will keep the bit in place, also clamp the plate tightly with a rag to prevent scratches, don't drill it holding the plate with your hands, you could cut yourself if it get's stuck, believe me, that happened to me once.

Step 5: Placing the Lid

Picture of Placing the Lid

Once you have the holes in the plate you can drill the holes at the bottom of the box using it as a guide, now is when the markings you made to keep the pieces aligned are useful.

Use a Dremel or drill bit slightly thinner than the diameter of the screw.

You can sand the aluminum lid later as if you just wanted to sand one side, just make sure it's tightly screwed and that you go to the direction where the wood part points and that you don't pass over the same spot twice. Aluminum powder is very dirty and easily stains the wood.

Step 6: Making the Circuit

Picture of Making the Circuit

Now comes the electronic part, all the information you need is at the picture shown above, make sure you have tested it properly before making the definitive circuit.

The 10k resistor is to eliminate noises (debounce the button), the 500 resistor is used to consume less energy when the button is pressed, but the Attiny still detects it as high

The tilt switch is quite useful because with a closed box you don't want to be opening and closing it all the time, if you want to turn it off, just flip the box and let it there, the tilt switch will deactivate the Attiny85 so no energy is consumed.

The tilt switch I built gives some problems, I would rather buy a mercury or a more stable one.

I managed to fit it all inside of it without too much trouble, I glued the switch and the LED first with thermofusible glue.

The battery is attached with electrical tape, I couldn't find a simpler and thinner way to do so.

Step 7: Uploading the Code

The code this project needs is really simple, it just has a random() function seeded by a micros() function and then some more functions to turn on and off the LED's depending on the random output.

As always remember that to upload the code to your Attiny85 you must go to >Tools>Programmer>Arduino as ISP and Tools>Boards>Attiny85 1MHz clock.

You can download the code here.

Step 8: Some Final Comprobations.

To check if the random function works properly I've taken note of 80 results, ending with 44 red and 36 green, I find it fair enough, it doesn't seems to show any pattern (thing that would be very strange if it's seeded by micros()).

As you have seen I've painted the box black, this is because such a small object tends to get dirty very quickly and the black color also highlights the grain of the wood. The black color comes from a thick permanent marker, it just does the job.

Step 9: The End

Picture of The End

Now you have a random decision box, use it with caution, even the slightest decision can have more power than what you can imagine.

Comments

theexternaldisk made it! (author)2014-09-16

Great simple party gift!

I changed the code a bit to get a random seed from the analog pin and rewired it so you only have to turn the box on via the push button (couldn't get my hands on a tilt switch).

Nice, I also built another one and I'm updating the code and writing a "mini game", I'll add new features soon.

King_Lee (author)Victor8052016-03-01

Oh, I'd like to see an Instructable for that, it looks so neat! :)

King_Lee (author)King_Lee2016-03-01

found it! : D

try a thermostat, the old ones used a mercury switch, and the newer ones use a ball bearing I think.

BenK6 (author)2015-05-30

int r = 0;
int g = 1;
int b = 4;
int val = 0;
int rn = 0;

void setup(){
pinMode(r, OUTPUT);
pinMode(g, OUTPUT);
pinMode(b, INPUT);

}

void loop(){

val = digitalRead(b);

this code i got from youre drop box is not working .or am i making a mistake?

Victor805 (author)BenK62015-07-11

There's some code missing in there, check again.

perfectsleeper (author)2015-07-06

Awesome for drinking game.

adam.verner.790 (author)2015-05-17

there should be switch to turn off the battery or it will drain extremly fast

Yes, that's why I thought about adding a tilt switch, when in idle it draws something around 1mA, this current is enough to keep it working for several days before the battery runs out. The attiny85 can go into sleep mode, but I haven't figured how to do it yet.

FrancescoB1 (author)2014-11-01

very well made project: it's easy and powerful but... you can just flip a coin...

Raffaduino (author)2014-10-15

Hi man! so, first greetings from Italy! second, i have a little problem, i uploaded your sketch to the attiny from my arduino uno. then i tried the circuit on the breadboard. here is the problem, it always gives me the Red light, never the green one. and if i change (swap) the Connections it gives me always green, where is the problem? thank you very much in advance!

Victor805 (author)Raffaduino2014-10-16

I'm not sure about what might be the problem, the code worked fine before uploading it. Check if the you're using the correct pins (0 and 1, which are actually 5 and 6).

Make sure to run your attiny85 at 1MHz. You can try using Serial.begin(9600); and Serial.Print(rn); to see if the random number is being repeated. But again, I think the code is ok.

Raffaduino (author)Victor8052014-10-17

Thanks for answering, i tried to upload it again, and the problem persists. a friend of mine tried it too and he has the same problem!
i need help!

Victor805 (author)Raffaduino2014-10-20

I found the problem, seeding with micros() might cause errors in some cases, find the function "randomSeed(micros());" and substitute micros() with millis(), like this: "randomSeed(millis());"

This is quite strange, because the new version I've made uses micros with no problems.

Raffaduino (author)Victor8052014-10-23

:) thank you man!

Victor805 (author)Raffaduino2014-10-26

Cool! Right now I'm breaking my head to code the new version, the mini game is quite difficult to program since I believe I'm exceeding the attiny85 memory resources and I need to find a way of overcoming it.

Raffaduino (author)Victor8052014-10-22

It works man!!!!! THANK YOU VERY VERY MUCH!!!!!!
soon the photos of my decision box! awesome istructables! :)

tyler roberts (author)2014-08-05

hmm, maybe we'll see a new batman movie in the distant future were two-face uses one of these?

Victor805 (author)tyler roberts2014-08-06

Lol, coin flipping is more classy.

tyler roberts (author)Victor8052014-10-05

yeah, but he'll need to get hold of a physical crypto-coin if he wants to keep it up years from now.

jermani eaves (author)2014-08-16

this is pretty cool

broach (author)2014-08-08

Nice looking box!

Wow. A 'coin flipper' was one of the first electronic toys I managed to make, way, way back in the seventies, back when circuit components were definitely more, well... discrete! I'm pretty sure it was a two transistor circuit though. Maybe that's why the whole idea of using a dedicated, programmable microprocessor/controller for such a relatively simple circuit seems like hiring a brain surgeon to open an aspirin bottle. Still, it's a lovely looking piece! I also remember using mercury switches in my toys for the same power-saving reasons!

When you've lived through all the electronics 'revolutions', it's tough not to feel a bit jaw-dropped when you see how casually even simple circuits today are programmed, rather than designed. (Somehow, I can't help getting the Monty Python song, 'Every Sperm is Sacred' out of my head! Except I might substitute 'transistor' for 'sperm'.)

Let me just grab my walker and I'll be movin' right along....

There were also a lot of these circuits made using 555s. (here's a typical one from 2009: http://goo.gl/YVsHv5

Made me wonder if you took a newer, $2 micro-power version of the 555, and made a few minor tweaks to run it on 1.5V...

I seem to recall another design that used two pinheads as a 'touch switch' to activate the circuit. With the right low-power device and circuit, maybe you wouldn't even need to worry about power drain -- and any extra switches.

Victor805 (author)broach2014-08-08

I agree with you, analog circuitry is being substituted by more advanced programmable chips, and in most of the cases, those chips exceed the power you expect from them to have in order to complete such simple tasks.

I would like to get into more projects like the one provided at the link you posted, but it won't be possible until I have more knowledge about electronics and I can design those circuits by myself.

Respect to the internet, there are lots of information about how to blink an LED with a Raspberry Pi, but if you want to look for analog circuits its quite more difficult to find.

I think analog design is dying and I feel bad about it, the people who broke their heads to make a those circuits are real electronic engineers, now electronics just seems to be a branch of informatics.

broach (author)Victor8052014-08-08

I guess it is what it is when it comes to analog vs digital circuits. I wouldn't feel bad about analog dying -- it's more, I dunno -- 'resting'. But then so is cartography, letterpress, cathode ray production, slide rules -- stuff comes and goes. The important thing is to keep an open mind and connection to older technologies and remember that there was a time when yes, people could do things like manage a large city's water distribution, or send men to the moon using less digital technology than you find in a iPad. The only 'mobile device' most of these designers had was between their ears (okay, there were those slide rules).

I think analog circuits, by nature, brought designers closer to... well, nature. That is, you really had to understand analog relationships, not so much quantum ones. I think it's great that you're plowing into electronics this way, or any way at all. Most of my early stuff was built out of salvaged goods, on the cheap -- built around the parts-safaris my brother and I use to make to the city dump on Sundays, pliers and screwdrivers in hand. It was a lot of fun!

My brother is still designing by hand -- working now with surface mount components on tiny wee boards through mag lenses, as part of his scientist prototyping work. We both still laugh over the great difficulty we have resisting the urge to scoop up old electronic junk we see put out on the curbside. We had the great advantage of being too young to know that we weren't supposed to be able to do half the stuff we did. It's a good trait to hang onto. All the best with your fun!

And just a note: not everyone broke their heads over these circuits. A lot of us just etched the boards, followed the schematics and enjoyed the ride.

Hey, I just remember one of my most popular 'tiny' toys I made back then: a simple blinking led 'metronome' inside a walnut shell. Nut shells make for interesting 'packaging'. The shells can be quite tough stuff! I also worked with coconut shells as housings. Maybe you'll consider trying that sometime. It was fun!

Victor805 (author)broach2014-08-14

The walnut shell case is quite a good idea, I eat plenty of them, It could be quite cool to put something inside of it, maybe I could make a prank walnut that vibrates or emits a weird sound when you grab it.

Also thank you for writing to me, knowing what experienced electronic engineers think about this whole thing is interesting.

broach (author)Victor8052014-08-14

Experienced electronic engineer? That's good for a chuckle or two. No, I guess it was more of a hyper-curious youngster (not unlike yourself?). Though I guess I did inspire my brother to become an engineer, in some way. I've just always liked to know how things really worked. But shortly after I got into art and design -- and found that trying to figure out how people's minds work to be even more interesting. About the only thing I use the electronics experience for now is repairing stuff. Though ironically, for someone who used to spend so much time trying to miniaturize circuits, most modern ones are too tiny for me to properly work on now!

One of my favourite little handheld toys from that period were handheld shock-boxes-- usually wrapped in alternating strips of metallic foil. They also included a mercury tilt switch. I'd leave these around my workplace and inevitably some curious hands would pick it up (without asking) and before they could even get 'What's this?' out of the mouth they would activate the shock circuit and drop it quickly. Trickiest part was making them solid enough to survive drops to the floor!

Enjoy making, designing, exploring and learning! Play it right, and it never has to stop.

alcurb (author)2014-08-11

Very elegant design.

I like the tilt approach for switching it on. The only loss while off would be battery's shelf life--that's it.

When you sampled 80 times and got 44 and 36, I expected something closer to 50/50. I'm not sure what the micros() function depends on for seeding the the random() function, but it's been my experience that machine code eventually falls into a pattern, even with a seed generator . When I coded in the past, I used the human component to seed the random function. Here's an example. You press and hold the button; the machine counts really fast; you let go of the button and the machine stops counting and arrives to 'x'; you then use 'x' as your seed. Humans do have an internal clock, but the accuracy is never down to less than a microsecond, so humans can be reliable random seed generators as the coin tossers.

Just for fun, I was thinking that it might be interesting to use an RGB LED instead of an RG LED. The blue result could mean 'maybe' or 'try again'

BTW: a little key bounce is a good thing to add a bit more randomness.

Cheers

Victor805 (author)alcurb2014-08-11

I'm very busy at the moment but I will retake this project and update the code to add an energy saving mode. I want to keep playing with Attiny's because I want to get into AVR's.

I'll try it again with 100 results to see if that variation could be just causality. I was thinking about lighting red and green at the same time to create an orange color as "uncertain" or as you said "maybe" or "try again".

kondzio29 (author)2014-08-11

You get my favorite. Idea is simple, but I like that you made case yourself, not just 3D printed it. Cheers!

nliwilson (author)2014-08-08

I like it. :)

The Lightning Stalker (author)2014-08-07

If you enable weak pullups on the Attiny, you can eliminate the resistors.

dewder74 (author)2014-08-07

does the tilt switch complete the circuit to send power to the Attiny85 and the micro switch, which is connected to input 2(pin3), is sending a high signal to the Attiny85 which makes the program run?

Victor805 (author)dewder742014-08-07

The tilt switch closes the circuit to send power to the attiny, this is just in case you don't want to do more holes to add a switch. When the circuit is closed, part of the program is constantly running, it's looking for changes at pin 3, where the switch is connected. When you press the switch, the attiny detects a HIGH value at that pin, and then another part of the code is run, the random() function is called, which selects a number between 0 and 1, if it's 0 the red light is shown, the same occurs for the green light when the 1 is the result.

The random() function is seeded by the micros() function, when you seed the random function with a changing variable (micros() in this case) you are adding more randomness, because the random() function has a list of determined values that are selected according to the algorithm of the function, when you seed it you are altering the normal operation of the random() function, getting more quality.

I tried to seed it with analogRead(), but for some reason, results seem to be very biased, so instead I seeded it with micros, since it changes at a very high speed it's very good to use it when there is an human factor.

You can download the code at the step 7.

dewder74 (author)Victor8052014-08-07

Thanks for replying and clearing things up. It's time to find parts and start fabricating! :)

acegard (author)2014-08-07

I like the project! I'd just like to correct a couple minor inaccuracies in your resistor descriptions:

The 10kOhm resistor is a "pulldown" resistor, so it does not debounce the switch (though that can very easily be done in the ATTiny's code), but rather it ensures that the ATTiny's input is at a "LOW" state while the button is open but also that it is then left at HIGH when the button is pressed. It also keeps it from shorting when the button is pressed.

The 500 Ohm resistor is unnecessary. When the ATTiny's pin is configured as an input, it is in a high-impedance state, meaning that negligible current flows into it anyway.

Kinnishian (author)acegard2014-08-07

Nahhh, easiest option is to make the button a momentary on switch and have that turn power to the attiny :).

Idk, there are a thousand ways to do it. Eventually your sleep mode is still going to drain the battery. Assuming 2uA draw, the CR2032s have 220mAh, your battery would also die eventually (URP! Looks like that would take 12 years...not so bad. but I'm not sure it would only draw 2uA).

I agree that debounce should be done in software.


All in all Idk if I'd make the same choices as OP, but the final design aesthetically looks great! project idea is nifty

elbowmanufacturing (author)2014-08-07

Here's an idea for reducing parts count, remove the tilt switch and put the uC to sleep using a sleep function you can find fairly easily on other postings. Configure the sleep so that button press wakes it up, then do the decision thing. Current draw in correct sleep mode is only 10 uA so it's almost as good as turning it off.

Thanks for the suggestion, it's a very good idea, I often leave things on without noticing and It would be very nice to avoid draining the battery after some minutes have passed.

dewder74 (author)2014-08-07

Looking at your schematic, it looks like the micro switch is sending a "high" signal to analog input 2(pin3). Without seeing a description of the program, I don't understand what the input tells the Attiny85 to do. I'm guessing that pressing the button changes the sequence of how the program randomly selects a output. Is that right?

dunnos (author)2014-08-06

This is SCREAMING for a drinking game...

littlemattyp (author)2014-08-05

I Made it! i even made an instructible of me making it. i meant to tag you in it but wasnt sure how, if your curious have a look at mine.

https://www.instructables.com/id/Desicion-Maker/

thanks for the great idea!

Victor805 (author)littlemattyp2014-08-06

Wow! Looks great, even better than mine, I wish I had some good wood to work with, I just have pine at the moment. The metal shells of the LEDs makes the whole thing look very neat.

You don't have to tag me, I don't do these instructables to gain recognition, I just make them to have fun and to let other people enjoy them.

badideasrus (author)2014-08-02

what if the decision is weather or not to use the cube? :P

i like it. it's simple and fun. a variation on it could be to make a code that outputs to one of a number of LED's, each of which are associated with a particular outcome, kind of like an 8 ball. 'not now' 'try again later' 'yes', ect. mmmmmm.... i'd use a lazer etched sheet of brass that has the outcomes etched into it. dangit now i have another thing i wanna make DX. *adds to ever growing list*

Ploopy (author)2014-07-31

Cool!

I just got a new arduino nano and i might just build this to test it.

Victor805 (author)Ploopy2014-08-02

For the price of an Arduino nano you
could buy a handful of AVR chips, that's the good thing about them, you
can use them for projects without caring about having to take them
afterwards because they're too expensive to buy another one.

I
suggest you to try the Attiny85, they can be easily programmed with
Arduino and a simple homemade adapter, they cost like $3 each.

wobbler (author)2014-08-02

I like it, but I'm not sure whether to make one of these or not. What I need is an Arduino decision box.

wilgubeast (author)2014-08-01

Binary magic 8 ball! Clean presentation, nice enclosure choice, and the "paint" job is just about perfect.

This is an awesome, "what do we have around the shop that I can put together in an hour?" kind of project. Pretty much perfect for those of us who can't flip coins.

Victor805 (author)wilgubeast2014-08-02

Thanks, I'll probably work on a similar project to make a Simon game with Attiny's as a gift for a relative who just had a child.

Kminek (author)2014-08-01

You can do an electronic dice this way using piezo as shake sensor but smd parts would be better then.

About This Instructable

68,928views

474favorites

License:

Bio: I'm an electronic engineering student. I don't usually have much spare time but I like to work on random projects to keep myself ... More »
More by Victor805:Quick and Easy Office Chair FixMake Golden Coins (really Easy)The Joule Blinker
Add instructable to: