Introduction: Digital Rattle


while learning how to blink a led with Arduino (!), i read that if the frequency is too high, you won't see the blinking anymore, although it's still there. The way to see it is to move the board very quickly, and due to persistance of vision, the eye can catch a series of dots.

I found this cool and thought of using this property to display slightly more advanced patterns, like geometric shapes and letters. There are many such devices, attached to a motor, that does the job pretty well. But I wanted something very light, that you could take anywhere.

I thought of a stick with a bunch of LEDs that you could shake to display something. One of the challenge was the frequency : to make the word visible, it has to appear every time at the same position. So the idea was to have a sensor detecting if you are moving the stick on the left or on the right, and display the characters in one direction or another. The other challenge was the Arduino board, that is too big to carry and shake. So I went for its mini version, the ATtiny 85, that can be operated with a simple button cell. The problem is that there are only 5 input/output ports on this chip, and I wanted 8 LEDs + 2 input ports for the left/right sensor. So I incorporated a Shift Register chip to take care of the 8 LEDs while using only 3 ports.

Step 1: The Diagram

It's pretty simple, the ATtiny 85 detects any left or right movement of the rattle, and send a sequence of light patterns to the Shift Register to turn on the right combination of LEDs. Since the cell provides only 3V, there is no need of resistors for the LEDs. The only 2 resistors are pull-downs attached to the left/right sensor, so the ATtiny 85 won't behave crazily.

Step 2: The Ingredients

So what you need here is :

- a prototype board (if you can make your own PCB, the process will become much simpler and faster)

- a ATtiny 85 chip with a socket

- a Shift Register

- 8 LEDs

- 2 10k resistors

- a switch

- a button cell with holder.

I cut the board into a stick, with steel ruler and cutter.

Step 3: Arranging the Components

I placed all the component on the board, in this order :

Battery holder, switch, ATtiny 85, Shift Register, LEDs.

The order is not very important, but keep a space of the motion sensor at the opposite end.

Then I started soldering them all.

Step 4: The Motion Sensor

It sounds like a big word, bu in my case it's a little ball of solder attached to a very thin wire, hitting 2 little plates of metal, weither it goes on the left or on the right. If you fish, you probably can attach this little piece of lead that goes below the floater.

I attached these 2 little plates of metal to a pin and soldered them at the end of the stick.

In a little piece of plastic pipe, I melted a ball of solder wire around a very thin thread of copper.

I finally attached this thread to the board and placed the ball between the plates.

Step 5: Connect Everything

The rest is, with the help of the diagram, connecting the components together. As it's very small, I used insulated copper wire.

Step 6: Design the Pattern

All you have to do is design your pattern on a grid, 8 cells high, where a black "pixel" is a 1, and a white is a 0. Convert each column into an integer. This number will be sent to the Shift Register to display the right combination of LEDs.

For example, the exclamation mark (!) shown here is coded as :









or 11111101 , that become 191 in decimal.

To make it simple, I made a Google spreadsheet :

You can simply enter a "1" on the grid where you want the pixel to be black, and copy the whole sequence of integers to be pasted in the Arduino code.

Step 7: The Code

Here is the code I used to display the pattern "LED!!!" :

int latchPin = 1;
int clockPin = 2; int dataPin = 0; int leftPin = 4; int rightPin = 3; int side = 2; int patt_len = 37; int pattern[37] = {0, 0, 0, 0, 0, 0, 255, 128, 128, 128, 128, 0, 255, 137, 137, 129, 129, 0, 255, 129, 129, 129, 126, 0, 0, 191, 0, 0, 191, 0, 0, 191, 0, 0, 0, 0, 0 }; // LED!!!

byte leds = 0;

int i=0;

void setup() { // put your setup code here, to run once:

pinMode(leftPin, INPUT); pinMode(rightPin, INPUT); pinMode(latchPin , OUTPUT); pinMode(dataPin, OUTPUT); pinMode(clockPin, OUTPUT);


void loop() { if(digitalRead(leftPin) && side==2){ side = 1;

delay(55); for( i = 0; i<patt_len; i++){

leds = pattern[i];
updateShiftRegister(); delay(2); } leds = 0; updateShiftRegister();

} if(digitalRead(rightPin) && side==1){ side = 2;

delay(55); for( i = patt_len-1; i>=0; i--){ leds = pattern[i]; updateShiftRegister(); delay(2); } leds = 0; updateShiftRegister(); }


void updateShiftRegister(){

digitalWrite(latchPin, LOW); shiftOut(dataPin, clockPin, LSBFIRST, leds); digitalWrite(latchPin, HIGH); }

Step 8: Upload and Test

There are many instructables to upload code to an ATtiny 85. I personally have this little device that helps me with this task.

Then mount the ATtiny 85 on the stick, press the switch and shake!

LED Contest 2017

Participated in the
LED Contest 2017