I/O:Force Sensing Showcase with adjustable LEDs
Demo Video:
A showcase that has a force-sensing function. It turns on when it recognized there is something put on it. While it’s on, the user can adjust the RGB values to change the LEDs’ color. It will automatically be turned off when the object is removed from it.
Reference:
All the Lab pages are mentioned in other posts.
FastLED Library : https://fastled.io/docs/3.1/
Start: Light it up
It all starts with a Neopixel Strip. In the beginning, I just want to play with it and make some cool stuff.
So the first step is to connect the LED strip to my circuit and confirm it works. The strip is connected to D3 in this screen.
Here is how I connected it. And after searching on the Internet, I found out that FastLED Library is required for this strip. So I add this library into my IDE and include it in mt sketch. The code is for let the No.0 LED blink in red and here is the result after uploading the file. It works!
Next Step: Adjustable colors
After confirming it works, I start to build up my idea. At first, I plan to make a Mood Light that allows the user to change color. But then I realize this strip is too small for a big room. Then I narrow down the goal to make a showcase for small figures.
The first step I did is to make the LED strip change colors, and here is the code:
In loop( ) function, hue is set for changing the color. The color mode I use for now is HSV since, under this model, I only need to change the value of HUE to change color. The first loop here lets the LED change from the first one to the last one and the second loop reverse it from the last one to the first one. Here is the result. fadeall( ) function here is to make a “tail” for the LEDs that fade out. However, in this screenshot, nscale8( ) and delay( ) is too small, so the result is not ideal.
At least it works! So I was head to the next step: add controllers to adjust the color of the LEDs. Three potentiometers are added since I want to use the RGB color mode and allows all of them can be adjusted. They are connected to A0, A1, and A2. To test whether they work, the code shown below is added. And I turn one of them in the middle, and another one to the end. The result from the serial monitor shows that all of them works well.
Then I need to convert the data from potentiometers to RGB values. So I used map( ) functions here to map the range to 0-255 for all three of them. then I can update my for loops to RGB mode and change the variables to what I want.
Then I upload the file to see whether it works. Here is the result.
Half-Time Break: More user-friendly!
For now, I have the main function I want. However, I found the wires are messy and the potentiometers are hard to reach and control for the user. So I reorganized the wire to make it more user-friendly. What’s more, I add colors on the top of each potentiometer to label which color it is controlling. Also, I add a pushbutton for the next step, The pushbutton is connected to D2.
One Step Further: Add a switch and update it!
For now, I want to add a switch that can control the on and off of this strip. As the circuit is shown above, A pushbutton is added. To make the pushbutton work, I updated the code: Only when the pushbutton is pressed, the LEDs would light up.
Then I realized that I can change the pushbutton to an FSR since the showcase only needs to be turned on when there is something on it. An FSR can get the weight of the object and recognized whether there is a thing on it. So I updated both the code and the sensor.
Polished a little bit:
All the features are ready now, However, it is not a showcase. The figure the user wants to show needs a place to stand. So I add a simple base for the LEDs. Also, the stand helps softer the light. The FSR is connected to the top of the stand, so when something is put on it, it would sense the weight of the object and turn on the light.
For further polish in the future, I’ve planned these things:
Wrap the wires and box them with potentiometers into a whole controller
Add a pedestal to the stand to make it more stable
Paint the SFR into the same color with the stand
Alpha Demo:
Future Possibilities:
There are some features I want to have but have not added to the project yet:
update the controller into a wireless controller like a Bluetooth controller or a wi-fi controller
color recognition function: LED color changes based on the object on the stand
sound recognition function: brightness changes based on the sound or the volume around it