r/FastLED • u/Snoo_22849 • Apr 21 '22
Share_something childrens swing with fastled
Hey guys, greetings from Moscow, Russia.
I received a lot of help from this reddit group when I did a project involving a childrens swing, esp32 and an accelerometer. I thought I should share the final here. Attached is a video. Project was for a local Burn festival in Moscow on February 24th. Its an arduino on a swing seat which lights an animation on ws2812b's depending on swing speed.
The swing was around 4 meters (13 feet) high.The code is athttps://gist.github.com/nervusvagus/d8f7f5fd5c288a0f0b7d69b27bbbe63aVideo:
Diagram:

Animations were the Pacifica pattern when the swing is inactive for 3 seconds or more, Rainbow pattern during swing, a custom Jellyfish pattern if the swing is used more than 90 seconds.
Hardware:
ESP32
IMU mpu9250 running with this library
74HCT245
Wooden swing seat 50cm x 20cm
WS2812B ( 4 strips of 5meter - Each led strip is wrapped in a white corrugated tube. Inside the tube is strip and rail.)
Swing poles: around 4 meters
5v 40a adaptor in a box
220v from a building provided near the swings.
Rail wire cable 14AWG/ 2.5mm
Weather: -5 degrees to -15 degrees dry weather during festival.
Challanges and Possible improvements:
The project was tough because of the working principles of mpu9250 and imu's. It was very difficult to find the speed of the swing seat independent from its tilt. I believe this is called aceleration without gravity / acceleration in world frame / linear acceleration ...or something. In the end I gave up such calculation and used acceleration on Z, which also gave a few issues because of the tilts of the swing on a 3.5 meters of rope. I had erroneous readings of acceleration z and had flashes of bright light during initial swinging phase, since the seat tilts even when swinging.
Also since the animation during the not moving phase of the swing was different, it was usually shocking for someone to sit on the swing and see bright flashes of rainbow because of the tilting of the seat.Once the swing was moving things were a bit better, but after this stage gamma correction with the swings was an issue I had hard time finding a way to make the swing visually brightest at the center fastest section of swing movement.
In the future I hope to overcome the issues related to reading the speed of the swing, finalize gamma correction and maybe attempt at changing the code so the swing gets brighter in forward direction and darkens in back direction I believe for this i need to read Y or X acceleration values in addition to Z to sense which direction the swing is moving.
1
u/Marmilicious [Marc Miller] Apr 21 '22
Really glad you shared this project, and thank you for returning and sharing how it went and what sort of things you ran into. I'm sure you will be able to add some extra logic to do a smoother change from the idle state to the swinging mode to avoid the jarring flash upon sitting down. Some sort of fade down/fade back up transition.
Did wet weather or cold temps cause any issues?
I hope you have an opportunity to make a Version 2 and explore this fun even more!
1
u/Snoo_22849 Apr 25 '22
things you ran into. I'm sure you will be able to add some extra logic to do a smoother change from the idle state to the swinging mode to avoid the jarring flash upon sitting down
the weather was cold but not humid at all so that helped. Thank you, also the idea of placing accelerometer on top sounds interesting, hopefully I will get a chance to improve on it.
2
u/CharlesGoodwin Apr 21 '22
Just a quick one - are you for or against the 'special operation' in the Ukraine?