To sleep, it's nice for a room to be really dark--no glowing leds and nightlights, but a little light would be useful for nocturnal bathroom breaks. Ghosty supplies some light only when you need it.
Ghosty will detect day and night using a photocell inside the 3d printed structure. An ultrasonic transducer is always watching for someone to pass by. If it's dark and you pass by, the ghost will illuminate. Ghosty will stay illuminated until 10 seconds after your next appearance (he wants you to make it back to bed), then he shuts off so you can sleep.
My wife, Annelle, molded the ghost using polymer clay. I scanned it and created necessary holes using a MakerBot scanner and TinkerCad.
My video camera doesn't have the same characteristics as my eyeballs, but here's Ghosty from a camera's perspective.
I did a little "thumbnail" analysis to see how practical (or not) it would be to produce Ghosty. For the prototype, major bits included Ping ($30.), Arduino ($25.) a 9 volt wall wart ($7.) and 100 grams of PLA filament ($2.50)--plus minor bits for a total of $64.50, not counting labor. Ouch!
A little searching on the internet showed that the ATTINY85 (I think I can replace the Arduino with this) can be had for $0.90 at digikey. The HC-SR04 (Ping replacement) can be found for $1.19. A 5 volt wall wart can be had for $2.12. The plastic should be $0.50 or less if made by a method other than 3d printing. This gets us to less than $5.00 for most material. So . . . maybe there is some potential for the project.
Another night with Ghosty, but he still performed erratically. Sometimes he would turn on when I walked by--sometimes not. If I went slowly, he would always work. What's going on? My suspicions centered around the little green light on the Ping transducer.
What if that light somehow convinces the photocell that it is daytime?
The hardware side of me wanted to pull the Ping out of Ghosty's head and crush the led with a pair of wire snippers! The software side (knowing that it's up against an adrenal filled "do something" junkie) protested.
"You might destroy the Ping and have to wire in a new one. You really don't know if that's the problem--let's at least prove it before you go on your destructive rampage."
Barely succumbing to the logic, I agreed to give it a little thought and one or two tests. In software I ask, "Is it dark? If it's dark, is anyone passing by? If no one is passing by, repeat." The "Is anyone passing by?" question fires up the Ping and lights the little green light. If this is done enough times, the inside of Ghosty's head gets fairly green and the photocell thinks it's daytime.
"So what?" argues my hardware side. The light is off when the "Is it dark?" question is asked. Our photocell friend, however, is what you might call, "a little slow." By placing a .2 second delay before reading the photocell the problem is solved.
At least, it's solved in my test room. Tonight, we'll find out for sure!
I tried Ghosty last night and he was a bit on the insensitive side (I had to get close to the counter to be reliably recognized). I increased the range in the Arduino sketch (available on this site). You can make software changes on Ghosty through the Arduino usb port (reachable through Ghosty's base).
The good news is that the single led (drawing 18 mA) provides enough light to see without shocking you into wakefulness.
I added a circular base plug (which can be tacked in with putty) to provide a more finished look.
I need to use a photocell for day/night detection. Ghosty does not need to activate if I am standing in front of him brushing my teeth. My 3d printed structure is porous, but how much light gets through? Do I need a hole through the surface for a photocell? I ran a test and my photocell (inside the structure) measures about 14K with daylight in the room.
In the dark (if it gets too dark, I can't read the meter), the resistance goes to over 100K (flash from the camera starts bringing the number down in the photo below).
This is good news, meaning that the photocell can be hidden inside the structure.