The simple device is made for detecting my mom's footstep my room while I am with my earphone. By turning the device on, the flashing light can tell me whether my mom is approaching, so that I can take off my earphone and listen to her carefully without being yelled at. (Sorry mom, I know you are tender most ot the time)
The device will detect vibration or knocks happen nearby, then transform it to the brightness of the led. The two varible of piezoReading and ledBrightness can also be read from the Particle Cloud, so that I can detect the condition of my room even if I am out, which might be very useful for pet owners with an enthusiatic dog.
First I tried to simply turn the led on and off when the piezo detects vibration to a certain degree, but found the light keep flashing quickly. I thought this might be because I couldn't get an accurate handle on the voltage range of the piezo element, so I fixed its range using map() and brightened the initial brightness of the bulb to make it easier for me to see if it's on or not, rather than only relying on looking at the switch.
For Next Steps I might add the function to turn in on and off via Particle Cloud. Also I still need to improve my understanding of building physical circuits and try to always add a semicolon when coding.
You can upload files of up to 20MB using this form.