Tilt Ball Sensor/Neopixels Mushroom Hat Prototype

by RaspJam in Circuits > Arduino

149 Views, 0 Favorites, 0 Comments

Tilt Ball Sensor/Neopixels Mushroom Hat Prototype

PXL_20211110_021953621.jpg
PXL_20211109_223054221.jpg
PXL_20211109_223013132.jpg
PXL_20211109_223030925.jpg

The final project is intended to be a mushroom hat that has a strip of neopixels around the edge that turns on when you put it on, and off when you put it down. **we will just be focusing on a prototype of the coding and wiring for this instructable, not the construction of the hat or putting it on the hat yet**

I made this mushroom hat for Halloween, with the intend of spicing it up later. My plan is to use a tilt ball sensor to trigger the neopixels to turn on. At this point, we have just the pixels turning on and off, but my final plan is to get the strip through different sets of colors. I have to troubleshoot that more first, feel free to give me suggestions of coding. But for now, enjoy looking through what I have done so far.

Supplies

Tilt Ball Switch (has no polarity)*

WS2812b (6 Neopixels) (a strip, be careful not to get the SMD unless you want to mount them yourself)

Breadboard*

Elegoo Uno R3*

USB Cable (attachable to Elegoo Uno R3)*

2 Female to Male Dupont Jumpers*

2 Male to Male Jumpers*

2200 uf capacitor

470 resistor

9v Battery and Snap-on Connector Clip (optional)*

*Obtained from the "Super Starter Kit UNO R3 Project" from elegoo.com

To Hook up the Neopixels:

Soldering iron (https://www.amazon.com/gp/product/B07WK5WGNK/ref=p...)

Solder

22 Gauge Wire Solid Core Hookup Wires (https://www.amazon.com/gp/product/B088KQFHV7/ref=p...)

Heat shrink tube

Wire Stripper (https://www.amazon.com/gp/product/B005JVJDIA/ref=p...)

Necessary Libraries:

Adafruit_NeoPixel.h

Connect Wire to Neopixels

PXL_20211110_171429023.jpg
PXL_20211110_171434505.jpg

You will see in between the pixels are three terminals (G (ground), Di (Data), 5V+ (the power)). You are going to want to cut three sets of your wire. I suggest picking black for ground, green for data, and red for power. I suggest strips of 6 in or so.

You then are going to want to strip your wires on both sides.

Then you're going to solder the wire them down to their respective terminals. *This takes some precision. Go slow and be mindful that your neopixel terminals should all be separate with no bridges otherwise they won't run.*

Once you're done, if your individual wires are still showing stripped parts of the wire, you are going to want to use heat shrink wire to cover up the individual wires. *Otherwise the neopixels won't run*

To keep everything secure also use heat shrink wire around all the wires and terminals.

Wiring

Glorious Lappi.png

We're now going to make the connections. Here is my diagram.

*Keep in mind that the tilt ball sensor is not accurately represented by the program since the system is limited*

*See in Program*

Code

Code 1.png
Code 2.png
library.png

I have linked my code here. My code is a mixture of the example codes from the adafruit neopixel library and the tilt ball switch tutorial from "Super Starter Kit Uno R3 Project" manual.

**Make sure to have the appropriate library downloaded. You can do this by going to sketch - include libraries - manage libraries - search "adafruit neopixels" and download the basic library.**

Some Tips for understanding and editing my code:

-Here is the information on how the code works from Adafruit: https://learn.adafruit.com/adafruit-neopixel-uberg...

-Mistakes I struggled with:

1)

if you use:

pixels.clear();

you cannot switch to:

strip.clear();

*You must either stick with pixels or strips, whichever you identified them as*

2)

make sure to use either command

strip.show(); or pixels.show();

to send the color commands to the neopixels otherwise it won't work

Connect Everything Together

Tilt Ball Sensor/Neopixels Mushroom Hat Prototype

Here is a video, explaining everything and then showing the prototype in progress.

Bibliography

Important info on the Adafruit Library:

“Adafruit NeoPixel Überguide.” Adafruit Learning System, https://learn.adafruit.com/adafruit-neopixel-uber... Accessed 10 Nov. 2021. (by Phillip Burgess)

This is where to find the tilt ball sensor code I worked from:

“Arduino Kits User Support.” ELEGOO Official, https://www.elegoo.com/pages/arduino-kits-support... Accessed 10 Nov. 2021.

This is the arduino manual I also used to source info:

Brian W. Evans. Arduino Programming Notebook. 2007. Internet Archive, http://archive.org/details/arduino_notebook.

As I was struggling to try and get the sensor and flashing strip working, I stumbled across this instructable. I was inspired to just start more basic from this instructable:

poppy.oceanblue. “Interactive Dandelion.” Instructables, https://www.instructables.com/Interactive-Dandeli... Accessed 10 Nov. 2021.

I include this project as well because I used it to better understand the neopixels:

Distance Sensor and Neopixels – Costumes and Sensors. https://www.uni-weimar.de/projekte/costumes-and-sensors/distance-sensor-and-neopixels/. Accessed 10 Nov. 2021. (by Theresa)