Pov Spinner

5,267

74

11

Posted

Introduction: Pov Spinner

So i was thinking: let's make something obvious.
This instructable is on making a spinner with a persistence of vision illusion inside.

Step 1: Parts and Wiring

  • ATtiny 45 ic
  • 5 smd led (1206)
  • 5 smd resistor (47 Ohm)
  • 2 small pieces of pcb
  • 1 coin battery (3v - 16mm)
  • 8 pieces of metal (for balance)
  • a piece of mdf (3mm) for the spinner itself
  • a 22mm metal ball-bearing (center)

The wiring is pretty straight forward. I followed the datasheet from Atmel (see screenshot above)

  1. The positive pins on the led go to PB0 - PB4 on the ic. I added a resistor in between.
  2. negative pins go to GND.
  3. Power the ic by connecting the battery to VCC and GND.

Step 2: Programming the Ic

In order to put code on the Attiny we need to follow a few steps:

  1. Upload the 'ArduinoISP' example to the Arduino board ( located in the examples folder)
  2. In Arduino preferences point to https://raw.githubusercontent.com/damellis/attiny... or look for attiny library (by David A. Mellis) and install it
  3. In Tools> programmer select the ‘Arduino as ISP’ option
  4. Attiny 45 runs on 1 Mhz but can be changed under ’Tools’. That's a bit to slow for persistence of vision: change it to 16 Mhz (normal clock on a regular Arduino)
  5. If you do the previous step you have to burn the boot loader. (Tools > burn bootloader)
  6. wire the Attiny to the Arduino board (see this page for the exact wiring or look at screenshot above). You also need a 10 uF capacitor between reset and ground to avoid reset (and starting the bootloader)
  7. upload the code below to the attiny.
  8. done.

arduino / attiny code from the spinner:

<p>int letterSpace;<br>int dotTime;</p>byte invader[] = {1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0};
byte invader2[] = {0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1};
int amount = 12;
void setup()
{
  // setting the ports of the leds to OUTPUT
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  letterSpace = 2;
  dotTime = 1;<br>}<br>
void printImage(byte pix[]){
int y, i;
// image
for (i = 0; i < amount; i++) {
	for (y = 0; y < 5; y++) { 
		digitalWrite(y, pix[y + (i * 5)]);
	}
	delay(dotTime);
}
// space between images
for (y = 0; y < 5; y++) {
	digitalWrite(y, 0);
}
delay(letterSpace);
}
void loop(){
	printImage(invader);
	printImage(invader2);
}

Step 3: Simple Spinner Images

create images

The spinner needs an image to display so i've made a small browser page to create sequences / images for the spinner. (attached as file)

It has an interface of multiple input tags (type: checkbox) and two functions: one to create a new column and one to create the sequence of 0 and 1.

My son (6) had a good time making some invader like sequences.

js:

var start = 8; // start with 8 columns

// a function to create a column of inputs. i have 5 led in the spinner..
function makeColumn() {
  var box = document.createElement("div");
  box.id = "col"; // check css for styling.
  for (var i = 0; i < 5; i++) {
      var input = document.createElement("input");
      input.type = "checkbox";
      box.appendChild(input);
  }
  document.body.appendChild(box);
}
// function attached to load event. Creates the buttons and the columns based on the amount stored in start variable
function create() {
  var b = document.createElement("button");
  b.innerHTML = "create";
  b.addEventListener('click', generate);
  document.body.appendChild(b);
  var b2 = document.createElement("button");
  b2.innerHTML = "add row";
  b2.addEventListener('click', addNew); // event for adding a new column
  document.body.appendChild(b2);
  var input = document.createElement("p");
  input.id = "result";
  document.body.appendChild(input);
  for (var i = 0; i < start; i++) {
      makeColumn();
  }
}
// adds a new column
function addNew() {
   makeColumn();
   start++;
}
// function to generate the sequence of 0 and 1
function generate() {
   var inputs = document.querySelectorAll("input");
   var result = [];
   for (var i = 0; i < inputs.length; i++) {
       var r = inputs[i].checked ? 1 : 0;
       result.push(r);
   }
   var pusher = document.querySelector("#result");
   pusher.innerHTML = result;
}
// start everything when page is loaded.
window.addEventListener('DOMContentLoaded', create);

css:

#col {
   display: inline-block;
}
input {
   display: block;
   -webkit-appearance: none;
   width: 20px;
   height: 20px;
   background: black;
   margin: 1px 1px 0;
}
input:checked {
    background: yellow;
}

The spinner itself was made with NodeBox 3 - an interesting tool for design. The svg output is included.

4 People Made This Project!

Recommendations

  • Remote Control Contest 2017

    Remote Control Contest 2017
  • Arduino Contest 2017

    Arduino Contest 2017
  • LED Contest 2017

    LED Contest 2017

We have a be nice policy.
Please be positive and constructive.

Tips

Questions & Answers

11 Comments

I love this project, I made it myself

What I had to do is change the code of the image in reverse, so 1 becomes 0 and 0, becomes 1

And then I have another problem, the bottom 2 LEDs, connected properly, do not display the actual figure

Can you please help me?

Regards

Hi, thx for liking it!

I don't understand why you had to change the 0 - 1 sequence to make it work. Did you use the html page (included in last step) that generates the sequence?

I tried out a simple drawing first: once that works a more complex one will do fine. Make shure the amount variable is the amount of 'columns' (in this case: 9) in your drawing. A good idea is to change the variables for speed (dotTime and letterSpace) to see what happens. I tried to example below (following the instructable) and it seems to work fine. Are you shure the wiring is correct?

Hai ,

1000 x sorry, I found the error, it's completely my fault

The last 2 resistors were connected to each other on the ATtiny85 pins, pin 2 (A3 / D3) and pin 3 (A4 / D4)

And because I want to build as little as possible with ordinary components, it's a bit hard to see (my eyes are not too good after 63 years of Hi)

Thank you for sharing this project with us , I love it so match

Good that your problem is solved.
thx again for liking it!

something funny with the previous picture: the idea is a up an down cycle:the sequence i tried in the movieclip (9 columns : 5 led):

0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1

Have you patent it? Because you would loose the right by publically posting it..Shame because this is would be fascinating, too much for the uninformed buyer.

i'm out of luck then, it seems to be too late already :)
anyway: pov is not really new, i can't be held responsible for inventing the illusion, let alone patent it..

Thats pretty cool! Although I still don't undertand the spinner trend which I guess makes me an old fart :(