Chika Makes Things 2016

Week 12: Interface and Application Programming

Home

Goal: Write an application that interfaces with an input and/or output device that you made I am planning to incorporate motion activated lighting into my interactive doll house. I wanted to experiment with the motion sensor, which I had not previously tested in input and output devices week. I designed the board in eagle incorporating an LED and resistor, but did not end up finding lab hours that aligned with my schedule after Thanksgiving break. Therefore, I prototyped the setup with my arduino kit.

I chose to use node.js with serial port for communicating between my arduino uno and JavaScript and websockets within HTML for updating my browser. The following commands were necessary for installing these through terminal: npm install ws and serialport. I found Jasmin (2015 student) and Neil's javascript examples particularly useful.
I updated my arduino code, which began with lighting up a red LED as long as motion was detecting in front of the PIR sensor, by using Serial.write to send '1' hours for motion and '0' for no motion. In html, these values were requested through websocket and used to update the webpage. When a '0' was received, a black box with the word no next to it was displayed. When '1' was received, an orange box with 'Yes!' was displayed. My biggest challenges in incorporating this were making sure that serial was actually sending the values or interest and creating an if statement in HTML to change the colors of the boxes. After figuring this out everything worked out. JavaScript and HTML files as well as the final video are shown below.