When you go to the bathroom this light (very subtle) comes on--10 seconds after you leave, it turns off. Sleep well, move around safely.
Sketch Oct. 1
ino - 1.27 kB - 10/01/2016 at 18:41
sla - 237.41 kB - 09/30/2016 at 16:29
- 1.28 kB - 09/30/2016 at 19:31
Print using 5% fill with supports
sla - 449.59 kB - 09/29/2016 at 13:38
Print using 5% fill with supports
sla - 1.13 MB - 09/29/2016 at 13:38
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.
So how did yesterday's software change work? GREAT!
Ghosty never skipped a beat and responded correctly to every approach. The green light on the Ping transducer was activating the photocell and that was causing the odd responses on previous days.
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.
Insert the Ping Transducer into the eye slots in the head (friction fit).
Add the led and the photocell. I taped them in place using duct tape.
Here's another view of the head.
Plug the wires into the Arduino.
Here's a better view of the Arduino.
Insert the jack from the power supply through the hole in the back of Ghosty.
Plug the power jack into the Arduino.
Here's what Ghosty looks like tacked together (for now the head is connected to the body using Velcro White Tak Putty).
If you are curious, here's the clay ghost that was scanned and modified to become Ghosty.
Here's the diagram showing the way parts are assembled:
This is the led--note that I have shrink wrapped all exposed conductive surfaces.
This photo shows the Ping transducer, photocell and 30K (approximate) resistor.
Note that the Ping transducer has only three pins--many similar devices have four pins and that impacts the circuit connections and software.
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.