Process
There were four levels to completion of our project: Basic - Status Indicator, Intermediate - Sensor Feedback, Advanced - Visual Alerts and Expert - Connect to the cloud by a remote alert.
For the basic status indicator my goal was to blink a light when the sensor was collecting data. This included just a LED, accelerometer, photon and pushbutton. A few comments were that the LED turned out to be more of a task than I expected because I had to learn how to blink the LED without delay because the delay messed up the sampling rate of the accelerometer. Also, calibrating the accelerometer took a lot trial and error.
Next I added another LED to the system that adjusted the brightness based upon how high the accelerometer reading was. For this I had to characterize the accelerometer (I shook the accelerometer as much as possible to register a maximum value) and I used the map function to take the accelerometer data and turn it into numbers that I could register on the PWM range.
For the advanced level, I added a light that blinked three times to indicate that the cycle was finished. This was the largest coding task as the logic to register when the washer was done had to be developed and because it's linked to the shaking of the accelerometer I had to account for the edge cases: the sensor getting tapped accidentally and a random drop in the amount of shaking while the washer was on. To handle the first edge case, I used a wrote a function for a simple low-pass filter to make the system less responsive to major changes. The filter required some tuning (i.e. determining the value of alpha [see code]). The value also became a float when used in the filter which prevented the sensor feedback light from working so I pass the int function to the result of the filter in every loop. The second edge case was covered in the regular loop using boolean values for “on” and “delay” to ensure that only significant changes were registered
Finally , for the expert level I had the photon send me a text when it registered that the cycle was finished. I used “If this then that” to send a text message to my phone once the cycle was registered finish. Using “if this then that” required understanding how Particle.publish worked but once that was accomplished it was relatively easy to add into the rest of the code