Back to Parent

Outcome


Outcome

This device is a burglar alarm. It uses a photoreceptor to detect if a door is open. If the door is opened, more light is let in, which trips the photoreceptor threshold and lights up the LED. The LED event is sent to the Particle Cloud where it triggers a text alert to your phone (this last part is represented by the LED lighting up). The device has a switch to turn the alarm on and off. When you leave the home, you turn it on; when you arrive back home, you turn it off. 


You can see it in action here: https://www.youtube.com/watch?v=QJxgrz5n1jo

Process

  • To make this alarm, there were two processes I needed to make work. First, the switch needed to turn on/off the alarm system (photoreceptor + LED), not the LED. Second, the alarm system threshold so that the LED would turn on only when the light sensor was > 3000. 
  • I struggled to figure out where how to adjust the void loop to make this work. If I separated each process one after the other in the loop, then when the switch was off, the light sensor would turn it back on as the loop repeated. So, I nested the photocell threshold instructions within the if/else switch statement. This created the desired effect. 

Reflection

  • The biggest challenge was learning the syntax of the if statements and getting the brackets in the right place. It was satisfying to start assembling different functions to solve this problem and build a small alarm system. 
  • If I were building this for real, I wouldn't use the LED; I would send the photocell data to the particle cloud and have the > 3000 reading trigger a text message to the user. For this project, I used the LED lighting up as a proxy for that notification. I did, however, include the code to send the photocell data to the particle cloud. 

Show Advanced Options
Drop files here or click to select

You can upload files of up to 20MB using this form.