Introduction: Sonic Fish Night Light

About: The answer is 42!

I wanted to create a mood light or night light that would have a different kind of user interface, one that would be fun to use. I looked at several sensors in my vault of bought, but not used yet purchases. I decided I hadn’t done to much with the ultrasonic sensor. Waiving your hand and having something happen is such a cool Stargate/Startrek type of device! J That statement makes me want to build a Stargate. But I digress.

Video of the Fish in action:

Step 1: How It Operates

The Fish has an ultrasonic sensor in the top of the fish. The sensor is pointing straight up. The senor can read a distance of up to seven feet. I however have only programmed it to recognize 2 of those feet. I can expand that later to add more fun features. Now when you place your hand above the sensor within that 2 feet area then the leds change different colors. The colors range from variations of blue (1 inch above sensor) to Red (24 inches above sensor) and all the variations of red and blue inbetween. I have set the power output for leds low so as to be used for a mood light or night light. However with just small changes to the programming you could make it super bright and flash for a rave or party type of effect. So lots of possibilities.

Step 2: ​Components:

5 X WS2812 neo_pixels $2: these are individually addressable RGB LED’s. these come in a strand of 30 or more. It is super easy to cut them up into smaller counts and use them for projects. It is my goto lighting component. These LED’s have a gnd, 5v and a signal line and solder points built into the strip.

9VDC wall wort $3 I get these at the local goodwill.

Parallax ultrasonic sensor 3 pin $30 from radio shack(closed now) however you can get them online.

Arduino Pro Mini or any Arduino of your choice $12. This in the microcontroller. The brain of the operation. You will upload your code to this to run the leds and sensor.

Soldering iron and Hot Glue Gun: this is for connecting and mounting the device.

Step 3: ​Schematic/Hookup:

I hooked the power pins for the LED’s and the sensor to digital pins on the Arduino is for a couple reasons. 1. I had plenty of pins to work with. If I had been cramped for space or lots of components that needed all the pins. I would have attached them to a mutual external 5v rail power supply. 2. This allows me to cut power to both components in my programming, instead of using a physical switch. True I could just make the sensor stop sensing or change the LED color values to zero. But I just decided to do it this way. If the components had been power hungry I would have just used an external power supply. However be warned turning power off to a sensor may extend your time in reading it because some sensors have to warm up before you get an accurate reading.

Step 4: ​How the Programing Works:

The sonic sensor detects distance in centimeters. I did not write this code. The wonderful people of Parallax did this for me J. That distance value is then stored in variable (cm) as an integer (whole number). The switch or case statement as its known then compares this value to the value of each case number. For example if your hand is 20 cm above the fish then the programming will pick case statement 20 and run it.

The neo_pixel statements have a function that wants 3 int variables. So I named them Red, Green, Blue. Green is always 0 for now. As I work with upgrading the programming, I hope to figure out a way to control all three colors. Red and Blue however work opposite of each other. Red gets brighter as Blue gets dimmer. So if you put your hand close to the fish the light will be blue with no red showing. Then as you raise your hand the the cm variable number increases. The variables red and blue are using the map function. This allows me to let the blue get dimmer as the variable cm rises at the same time allowing the red variable to become brighter. Hence the effect of transitioning from blue to red and visa versa as your hand goes back down.

Step 5: Code:

You will need to install this library into your arduino IDE

Adafruit_NeoPixel you can download it here at
Github (https://github.com/adafruit/Adafruit_NeoPixel )

Step 6: ​FTDI:

Using the smaller form factor I tend to run into FTDI communication issues. So here are a couple tips.

· As I plug and unplug for prototyping I tend to have intermittent communication. I have realized that my soldering is to blame. So if your chip is uploading sketches one day and then not the next. Try remelting the solder and see if that fixes it.

· Next if that did not work try youtubing FTDIgate. It’s a whole THING!!!!

· I generally just prototype with an uno or mega and then when I have it all down. I transfer to the smaller form factor.

Step 7: Upgrades:

·

When hand is directly on the sensor then the light turns off and when the hand passes the sensor again above one inch then the light comes back on.

· Use a cheaper sonic sensor to make the project

· Make a mincraft block version

Step 8: Contact:

Robopandapdx.com

facebook:Robopandapdx

twitter: @RoboPandaPDX

youtube: Robopandapdx

email: RoboPandaPDX@Gmail.com

Step 9:

Home Automation

Participated in the
Home Automation

Mind for Design

Participated in the
Mind for Design