Learn to code with this STEM fidget spinner


I am thinking for a while about how to teach young generation coding in a funny way. I come up with an idea of a fidget spinner with RGB LEDs and a microcontroller. This idea succeeded in attracting teachers’ and parents’ attention. But the most important part of the project is drawing students’ attraction. Of course being a fidget spinner doing its job but I am talking about the educational part. What kind of coding challenges and tutorials can we prepare? This is the reason I am writing to this forum. Please find some code challenge ideas that I came up with here but we can find others and betters Any help on ideas or preparation of a one-page tutorial content is appreciated.

The fidget spinner has an optical rotation sensor. So determining its speed and number of rotation is possible.

Note: For more info about the project you can take a look at it here it is entirely open source.


What a cool idea!

I’d recommend messages if you haven’t already though of it. Something like a swing-arm led clock:

led clock


Thanks, DaveC.
Yes, we have completed the code for displaying text.
We are showing the spinners speed as rpm. Or the spin count.


You can teach them binary number system and have the LEDs light up in that pattern… and see what the resulting spin pattern looks like!


Thanks, Owel great idea!
Counting in binary may result in some patterns while spinning.
I will try that.


Teaching PWM to vary brightness of LEDs
Teaching about colors, via RGB color mixer.

I think patterns + varying brightness + varying colors could make for interesting visuals.


Oh great. :slight_smile:
What about drawing a comet with PWM. A bright head and getting darker tail coming behind.
Great to brainstorm here.


Here is the other one. Drawing a rainbow (like your icon Owel) can be challenging.
with mixing red blue green


Yeah, teach about color wheel concepts…

  • primary, complementary, analogus, etc.


Teach about frequency (via the rate the LEDs blink) - fundamental, secondary harmonics.

Doesn’t have to involve spinning… but you can teach about binary operations via the the LED state.

Maybe Binary math? Using the PB switch to show the first digit, second digit, and the sum or difference of the two numbers, etc.

Counting in Binary, using the PB switch to increment++


I can not catch up with the ideas you are generating man :slight_smile: The board do not have PB switch (Does PB switch means Pushbutton Switch? )

But Counting in Binary, using the rotation switch to increment++ will be great.

I need clarification on the frequency and Binary operations like NOT or XOR can you please explain little more?


Yes, PB – push button switch

I though it’s got a switch?

I was thinking the 8 LEDs will have an initial state, as defined in Arduino code. ex:

1 1 0 1 0 1 0 0

and then the student press the switch to show what would happen if a NOT operation was applied:

0 0 1 0 1 0 11

or XOR’d with a pre-defined number in the Arduino code. (ex: student sets the number 8 for the second number)

1 1 0 1 0 1 0 0
0 0 0 0 1 0 0 0

1 1 0 1 1 1 0 0 (I guess this was a bad example, since result is just the same as an OR operation)


Say LED blinks at 1Hz, 2nd harmonics will then be 2Hz.
if LED blinks at 3Hz, 2nd harmonics will be 6Hz.
Maybe show 1st 4 LEDs blink at primary frequency, the rest of the LEDs at 2nd harmonic frequency.


That PB connected to Arduino reset so can not be used as an input signal. But there is a rotation IR sensor not populated in the picture but it is at the bottom can be used as touch sensor like a button.

Can I invite you and all other idea creators to https://lightino.org
You can add great value to our efforts.

I will work on the links. For the frequency; lighting the LEDs with harmonics may cause any visual effects?


I added Binary Counting as code challenge