Back to Parent

Outcome


Intention

I made this device for my roommate, Sonam, so she never has to come home to a dark house again.

Screen shot 2017 01 30 at 10.26.08 pm
Show Advanced Options

Process

  • First I looked at using RFIDs, but was advised against using that sensor as it can be difficult to work with due to security settings. I ended up using the Hall Effect US5881 and a magnet and started research how to set it up on a breadboard. It was small and really easy to work with.
  • Next I set up my sensor as input in D2 and my LED as OUTPUT in D0. I used 1,000 ohm resistors for both the Hall Effect and the LED. To make sure my circuit was working, I blinked my LED.
  • I wrote the following pseudocode to help plan my code and then looked online for sample content. I only had to make minor adjustments to get the code to perform the way I wanted.
  1. //Hall effect sensor detects a magnet
  2. //Turns on LED light
  3. //Sends a text message to roommate "Hey roomie, I'm home!"
  4. //Manually able to switch the light off

Product

This is a basic breadboard circuit configuration with a hall effect US5881 sensor that turns on an LED light. The code is programmed to turn on the LED when it senses a magnet nearby. The application of this in real life is, for example, a simulation of a magnetized key turning on the lights when the door is unlocked.

The code is programmed to keep the light on even when the magnet is removed. At first, my if else statement was turning it off when the magnet was removed. The fix was frustratingly simple! By deleting the else, the loop stopped after turnOnLED(); and the light remained in the on state. (See code below).

A three prong, one sided switch was added to be able to turn off the light.

Show Advanced Options
Show Advanced Options
Img 20170130 172409037
Show Advanced Options

Reflection

I didn't push myself as far technically as I could have for this project, but I still invested a lot of time. Rather than rush myself to finish it, I spent a lot of time watching tutorials, reading blogs, and understanding the sensors and code I was working with. The code I used was really easy to understand and applied to my project almost perfectly, but it gave me a chance to play with each line of code and really understand what was happening.

I tried working with the the NeoPixel RBGW Ring that I have, but couldn't figure it out given the deadline. I'm not giving up and I know we have course resources that could help me. Hopefully for my next project I'll be able to get them to work.

I also started to become more familiar with some of the help sites. For example, I didn't realize adafruit had a learning center: https://learn.adafruit.com/adafruit-neopixel-uberguide/neopixel-rings


Making the LED Stay On

Original if else statement where the LED light turned off when magnet was removed:

Show Advanced Options

Updated code where LED light stays on until manually switched off:

Show Advanced Options

Sending SMS Messages

I was able to send a message using ifttt.com but wasn't able to get the loop to stop firing, so I've since commented that feature out. So far the only solution classmates have found to stop the sudden barrage of sms messages is to add a really long delay in the loop (see below). The issue with this is that stops the code and makes the device unresponsive for whatever period of time you have set.

Code credit: http://integratedinnovation.xsead.cmu.edu/gallery/projects/turn-down-for-what

Show Advanced Options
Screen shot 2017 02 05 at 9.14.16 am
Show Advanced Options
Drop files here or click to select

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