Arduino Decision Box. (Attiny85)




I'm an electronic engineering student. I don't usually have much spare time but I like to work on...

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)

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 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

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

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

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

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

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

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



  • Indoor Lighting Contest

    Indoor Lighting Contest
  • Make It Fly Challenge

    Make It Fly Challenge
  • Growing Beyond Earth Maker Contest

    Growing Beyond Earth Maker Contest

46 Discussions


4 years ago on Introduction

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?

1 reply

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.


4 years ago on Introduction

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


4 years ago

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!

6 replies

Reply 4 years ago on Introduction

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.


Reply 4 years ago on Introduction

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!


Reply 4 years ago on Introduction

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.


Reply 4 years ago on Introduction

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.


Reply 4 years ago on Introduction

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


5 years ago on Introduction

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:

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.

2 replies

Reply 5 years ago on Introduction

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.


Reply 5 years ago on Introduction

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!