Introduction: Geek Spinner
Fidget spinners are fun, and you can find one at about any check-out counter for just a few bucks these days, but what if you could build your own? And it had LEDs? And you could program it to say or show whatever you wanted? If that sounds geeky cool, THIS IS THE PROJECT FOR YOU.
I've always been interested in using blinking LEDs to get kids interested in programming. The most simple project with an Arduino microcontroller is to blink an LED on and off. Then you get them to see how fast an LED can blink before it looks like it is on continuously (about 12 millisecond intervals). Then you shake the LED back and forth and you can see it blink again! This phenomena is call "persistence of vision" (POV) and is how this project works. It can lead to discussions of both how the eye works and how incredibly fast computers are.
This project uses a programmable 8-bit microcontroller, eight LEDs, and a coin cell. It spins using a standard skateboard bearing, and uses a Hall-effect sensor and a magnet to determine rotation. It is made using beginner-friendly through-hole parts and can be programmed using the Arduino programming environment. Enough talking, let's get making . . .
Step 1: Gather the Parts, Tools, and Supplies
It is always frustrating to get half-way through a build and find you are missing something. These are the parts I've tried and found to work well. Substitute at your own risk:
Bill Of Materials
=================
1 ea, Purple PCB, lovingly manufactured in the US by OSH Park
1 ea, Attiny 84, Atmel ATTINY84A-PU, https://www.digikey.com/short/3019qn
1 ea, Tactile switch, TE 1825910-6, https://www.digikey.com/short/31nmpp
1 ea, Slide Switch SPDT Through Hole, C&K JS202011AQN, https://www.digikey.com/short/31ffhj
1 ea, Battery holder, Linx BAT-HLD-001-THM, https://www.digikey.com/short/31ffmv
8 ea, 3mm Red LED 160 Mcd, Wurth 151031SS04000, http://www.digikey.com/short/33354d
8 ea, 330 ohm 1/8W, Stackpole CF18JT330R, http://www.digikey.com/short/333rf2
1 ea, 0.1 uF cap, KEMET C320C104M5R5TA, https://www.digikey.com/short/314jvp
1 ea, Magnetic switch, Melexis MLX92231LUA-AAA-020-SP, https://www.digikey.com/short/301931
1 ea, 608 Skateboard Bearing, http://a.co/foTx20l
1 ea, small rare earth magnet 2mm x 1mm, http://r.ebay.com/PbsyKc
2 ea, 3D printed caps (STL file attached).
1 ea, CR2032 battery, Panasonic BSP or equivalent, https://www.digikey.com/short/31f283
Tools and Supplies:
For my workshops, I use SparkFun's Beginner's ToolKit which has everything you need except the tweezers:
- Soldering iron.
- SolderWire
- Flush-cut plyers (I love the $5 Hakko CHP170!)
- Desoldering braid
- Super glue
Programming the Attiny (Step 4, not required if you buy this as a kit):
- Arduino (please avoid the cheap Chinese clones and support your US Open Source Manufactures).
A kit for this project is available on Tindie.com (minus the battery). Purchasing the kit will save you the time and expense of ordering from several different vendors and avoid the minimum PCB order premium. Also, programming an Attiny is not trivial, and if you buy the kit, it will already be pre-programmed. You will also be helping me develop and share other projects in my workshops!
Attachments
Step 2: Resistance Is Essential.
We are going to assume you have some kit-building experience. If you need some help soldering, head over to www.sparkfun.com/tutorials/213 to brush up or watch the Geek Girl explain it at https://youtu.be/P5L4Gl6Q4Xo. I also have a kit appropriate for beginners at https://www.tindie.com/products/3447/.
I like starting with the resistor because a) they are relatively heat resistant while you are getting into your soldering groove and the iron is coming up to temp, b) they have no polarity, so orientation is not critical, and c) they are the lowest component on the board so sit tight when soldering. There are eight 330-ohm current limiting resistors, one for each of the LEDs. You can do one at a time, or all eight at once.
- Bend the leads to the width of the pads and insert the resistor.
- Flip the board over and solder the leads.
- Trim the leads with flush cuts.
- Hit them again with the iron if you want them to impress your geek friends.
Step 3: Code?
If you bought my kit, the chip is pre-programmed and can skip to the next step.
Yes, this project needs some code. And, if you were paying attention, in Step 1 I told you that programming an Attiny was not trivial. I use the Arduino, it's programming environment, my AVR programmer, and a pogo pin jig.
The chip can be programmed before soldering in place (photo 2), or after it has been soldered in place using the ISP header on the bottom of the PCB (photo 3). In either case, the programming is as follows:
- Download the Arduino Programming Environment.
- Install support for the Attiny 85 from either:
- http://highlowtech.org/?p=1695 (Arduino Tiny)
- https://github.com/SpenceKonde/ATTinyCore (Attiny Core)
- Arduino Tiny: "Attiny 84 @ 8 Mhz"
- Attiny Core: "Attiny 24/44/84"
- Chip "Attiny 84"
- 8 Mhz (Internal)
- Pin Mapping "Counter Clockwise"
The biggest source of errors I get involve not having the pins aligned correctly.
Attachments
Step 4: Chip It
Now that your chip has code on it, you can install it. The orientation of a DIP ("dual inline package") chip is usually indicated either by a hole adjacent to pin one, or a divot on the end of the chip containing pin one, as is the case here.
- Bend the leads to 90 degrees by pressing them against a flat surface (photos 1 & 2).
- Align the chip with the symbol on the PCB and insert the chip (photo 3).
- Solder one pin on opposite sides, and check that both the chip is flat against the PCB and that the orientation is correct. It gets really hard to fix after this. Trust me on this.
- Once you are assured it is in correctly, solder the remaining pins and then cut them flush.
Step 5: Switch and Capacitor
The push button goes next to the IC, and the capacitor on the other side.
- Push the push button into place (ensure it is in the correct orientation).
- Solder it in place.
- Clip the leads off the back.
The capacitor does not have an orientation, but if you put the writing side out, your geek friends will know what value you used.
Step 6: Switch and Battery Holder
The switch goes with the level pointing outward. Like the other items, solder two pins in, check that it is seated flat, and then solder the remainder.
The battery holder has marking to show the orientation, but it really doesn't matter. It will, however, require quite a bit more heat than regular leads, and you will want to make sure it seated flat to hold the battery in position (picture 4).
Step 7: LEDs
There isn't a decent project that doesn't include at least one LED. This has EIGHT!
The long lead is positive (anode). There is a "+" mark on the silkscreen, and the pad is square. If you do all eight at once, hold them up to make sure you have all the orientations correct.
- Solder one lead on each LED.
- Verify the orientation and that they are seated flat (picture 3).
- If they are not, press on the case with your thum and re-heat the lead till it snaps in position (picture 4).
- Solder the remainder.
- Clip the leads.
Step 8: Check It Out
At this point, we can still check the LEDs and switch out:
- Insert a battery with the positive side outward.
- Switch the spinner on and then press the button until all (hopefully) the LEDs are on (see the video).
- Spin the spinner and see the pattern.If an LED does not light, it may be installed backward, or have been heat-damage. Un-solder it and put a new one in.
Troubleshooting:
- If no LEDs light:
- Make sure your battery is good and in the correct orientation.
- Did you program your chip? Is it in the right orientation? Is it getting hot?
- Are the LEDs oriented correctly? Use the coin cell across the led solder joints to test them?
- Check the solder joints on the LED.
- Check the solder joints on the Attiny.
Step 9: Spin Time
The bearing is held in place by soldering the case to the large pad. This takes patience and lots of heat:
- Use something like coins on a hard surface to position the bearing.
- Heat both the pad and the bearing shell until you see solder flow onto the case (it takes a bit).
- Repeat on the other side.
- Verify that the bearing is aligned correctly by spinning the spinner.
- Flip the board over and solder two points on the other side.
Step 10: Is This a Revolution?
In order to show messages instead of just patterns, we need to know the position of the spinner in relation to the circle. We will use a Hall-effect sensor and a magnet. This is similar to how combustion engines know when to fire the spark to get the most power. Orientation and alignment of both the sensor and magnet are critical for this to work.
- The writing on the face of the device faces the bearing matching the silk screen (photo 1).
- Align the height to just above the bearing (where the magnet in the cap will be).
- Solder one lead.
- Verify the height and aliment.
- Solder the remaining leads.
- Clip the leads.
If you are using an Omni-pole sensor, you will need to figure out the orientation of the magnet. The best way to do this is to set a mode other than the pattern from the previous step and then find the side of the magnet that starts the LEDs blinking (see video). Glue the magnet with the side that worked facing outward. Double check your work.
Step 11: Balancing Act
If you hold the spinner up horizontally with the battery in, you will see it pivot to the battery side down. Despite my best effort at balancing components, it is still off balance. You can add some weight to the non-battery side using a nut& bolt, or add some solder to the pad.
Step 12: You Are Operational
With your magnet and sensor in place, you are ready to check out the full awesomeness of your Geek Spinner. The mode of the spinner is shown by the LED that is lit on power up or after a button press (D0 - D7). The mode is changed by pressing the button (see video).
int modes = 8; // number of modes available // 0 -> text "Hello World!" // 1 -> RPM // 2 -> time in seconds // 3 -> spin count // 4 -> spin count (total) // 5 -> "lilly pad" pattern // 6 -> shape 1 (heart) // 7 -> shape 2 (smile)
Step 13: But Wait, There Is More . . .
The "heart" and "smiley" patterns were created by using a polar graph to show how the eight segments would look every 5 degrees of rotation.
By Hand:
- Download and print the full-resolution image (picture 1).
- Fill in the blocks to make your image (picture 2).
- Along the radial, starting a 0, calculate the byte using black = 1, white = 0;
- The first radial of the heart is 1, 0, 0, 0, 0, 0, 0, 0, so the byte = 0b100000000;
- Continue until you are done (hint, if your image is symmetrical, you only need to do half).
- Paste your bytes into the "textAndShapes.h" section of sketch under "shape_1[]" or "shape_2[]".
Using Python:
- Install Python.
- Install Python's Image library.
- Download the attached "readGraph.py" script.
- Download full-resolution image (picture 1).
- Open the image in your favorite editor (GIMP or MS Paint).
- Use the "Fill" command with black color selected to fill the segments you want lit (picture 2).
- Save the image in the same directory as the "readGraph.py" script and change the file name in the script to match it:
im = Image.open('heart.png')
- Run the script and paste the output into "textAndShapes.h" section of sketch under "shape_1[]" or "shape_2[]".
Either way, feel free to share your creation (picture and code) in the comments!
Attachments
Step 14: Credits and Final Thoughts
I certainly didn't come up with this all on my own. Not by a long shot.
- My first hands-on experience with POV was with a project from Nick Sayer called the POV Twirlie: https://www.tindie.com/products/nsayer/pov-twirlie/. (I also use is pogo adapter).
- The thought "LED + Fidget spinner = POV" popped into my brain after seeing Techydiy's Instructable https://www.instructables.com/id/LED-FIDGET-SPINNER/
- Any time you have an awesome idea, someone has already done it: https://www.instructables.com/id/POV-Arduino-Fidget-Spinner/. Surface mount soldering is something I can do, but not really beginner friendly. His code was also a little over my head, but I did use his ideas about displaying RPM and counts.
- I was able to understand and used snippets of Reger-men's POV Clock code to display text: https://github.com/reger-men/Arduion-POV-clock/blob/master/clock.ino.
No project is ever complete or perfect. Here are some thoughts I have going forward:
- Balance: Data sheets rarely have information about the weight of the components, so it is hard to make even an educated guess about the balance without just building it. The battery is obviously the heaviest component. I added holes on each end so I could add weight as needed to balance it.
- Clockwise? If you noticed, the text only displays correctly if you spin in the clock-wise direction. Spinning the other direction creates a mirror image. Adding a second Hall sensor or magnet would allow you to derive rotation direction (Sean's project did this).
- Color? Using programmable RGB LEDs would allow you to do colors. They are typically surface mount though.
32 Comments
Question 10 months ago
Amazing project. I built it but am having a few issues. The LEDs turn on and off randomly and the board occasionally works with the lily pad visual and blips certain shapes shortly but normally just turns all LEDs off. Due to availability, I bought an omnipole push-pull hall effect sensor (Part Number DRV5032FBLPGM) instead of the unipolar open drain switch you linked to. Is this perhaps the issue? Do I need to change the code / get a different hall effect sensor? Thank you!
Reply 10 months ago
I tried using a similar omnipole sensor without luck. If you dig into the data sheet, they have a very slow sensing rate (20 hertz) to be low-power. That is ideal for detecting a laptop lid opening, but not for measuring RPM. The RPM sensing is needed to display steady text and numbers. If you just want to show patterns, you can take the sensing part out the code.
1 year ago
Very cool project. I am a teacher in a Technical school and would ask you if you would accept to share the schematic and layout in aim to adapt it to the microcontroller that we usually used?
Reply 1 year ago
For sure. It is done in KiCad. Let me know if you run into issues:
https://github.com/aspro648/KiCad/tree/master/projects/Attiny/Attiny84SpinnerTHD_R3
Reply 1 year ago
Great we are also using Kicad in parallel of Altium.
Thanks a lot for this share!!!
2 years ago
Thanks for this cool project!!.I printed the 1.1 rev board and programmed the attiny correctly as well. But when I switch on, the leds light up from 1 to 7 then goes off, even push button doesn't seem to do anything.I know its been 4 yrs,but would be so helpful if you could reply.
Thank you
Reply 2 years ago
That sounds like it could be the pin-mapping error some others have run into. The first thing I would try is installing the ATTionyCore from https://github.com/SpenceKonde/ATTinyCore. They have a note about using Arduino IDE 1.8.13, which I would heed. When you select the Board, make sure the pinmapping is set to "Counter Clockwise".
Let me know how that goes and we can work from there.
Reply 2 years ago
Yea pinmapping is counter clockwise only sir. And I tried installing the attiny from the source as you said as well. Board that I gave is attiny84a (no bootloader). It doesn't work still, and I am programming the attiny using breadboard not using pogo adapter and all,if that info is of any importance.
Only difference is this time leds light up from 1 to 7 and reverses direction and then goes off. And i didn't get a battery holder of right pinouts so coiled a wire around like in the image😅
Reply 2 years ago
Hey, I think you might be alright. I don't have one here to test, but I believe that was the startup pattern, and then it is waiting for the signal from the hall-effect sensor to know it is spinning.
Seems like the led should advance each time the button is pushed to show what pattern it is on. Is that not happening?
If you don't have the hall-effect sensor, it should be possible to tweak the firmware so it still displays patterns. You will not be able to do letters or numbers because you will have no reference where you are at in the rotation, but you can still make some pretty cool POV displays.
Reply 2 years ago
I figured out my silly mistake, the tactile button was in the wrong orientation sir.
Now that I got all the setup completed with hall effect sensor ,magnet etc. But again the chip doesn't seem to work properly. It works when I touch the pin 2 of attiny84 with my finger. When I remove my finger ,the LEDs turn off
6 years ago
I successfully made the Rev 0.1 version of this spinner and was able to get it working after applying the code changes described in the comments for the Rev 0.1 Instructable.
I then bought the Rev 1.0 board and parts. After loading the SMD_spinner_THT_R2 code, the spinner is not working.
When I turn on the power, D3 through D7 flash on then D0 and D1 stay on dimly. The tactile switch does not appear to do anything.
Any help would be appreciated.
Reply 6 years ago
Sorry about the confusion. The different pin mappings for the different cores are tripping everyone up, including me.
I'm assuming you are using the Attiny core from https://github.com/SpenceKonde/ATTinyCore
When you select [Tools] -> [Board] -> [Attiny24/44/84], do you then get an option for "Pinmapping"? If so, select "Counter Clockwise".
Please let me know if that works.
Reply 4 years ago
Thank you! I just experienced the same issue, and was able to fix it using the ATTinyCore library. I'm using a USBasp v2.0 programmer with pogo pins, ATTinyCore has an option for selecting that programmer.
Reply 6 years ago
Excellent! After downloading ATTiny core from the URL you provided, the Pinmapping option became available. After selecting Counter Clockwise and reloading the code, the spinner now works as expected. Thank you for your help!
4 years ago on Step 14
Help needed. I completed soldering this project. When I turn it on the LEDs light up but after I spin it they go off after only a few seconds. The only way I found to get them back is to turn the device off and back on. Repeated several times. Thanks in advance for your help.
Reply 4 years ago
Sounds like the magnetic sensor is not getting a signal, so it goes into sleep mode. Verify that you have the cap with magnet on the same side as the hall effect sensor, that the sensor is facing the magnet, and that they are closely aligned. You can also test the sensor by removing the cap with the magnet and waving in front of the sensor and you should get the lights for several seconds. If that doesn't work, try holding it to the back of the sensor (it is sensitive to the pole, so the magnet may be in backwards). Let me know what you find.
4 years ago
The file used to print it is attached to Step 1.
If you don't have access to a 3D printer, or a friend who has one, check for a local maker space or at you library.
If all that fails, contact me and I'll hook you up for the price of postage.
Reply 4 years ago
couldn't find a 3d printer
Tip 5 years ago
Bearings linked to Amazon are not greased properly for fidget spinners. I used compressed gas duster to blow out most of it and sprayed a good amount of WD-40 and then used the duster on it again. It works pretty well after. Many online say that WD-40 as lube isn't great for spin times though. So you could use WD-40 as a degreaser and add a little of another lubricant. This seems to be a highly recomeneded one:
http://amzn.com/B0002FOGFI
5 years ago
Wow those bearings from Amazon barly move. Anyone found better bearings that fit this?