Compiling Arduino Code (continuation)
Using a delay function to enact a series of functions for varying time durations was practical and most effective for the first CSC demonstration. However, as I began to integrate more backlights and LEDs within the circuit, coding my desired functions began more complicated. It was clear that the use of a delay function was too primitive for the series of commands I wanted the WashBoard to enact. Therefore, I switched to using the ‘millis’ function.
The use of the ‘millis’ function allowed me to be able to control the durations for which LEDs would light up at each panel. Essentially, while each panel is illuminated— denoting the action to carry out— LEDs at each panel should change from green, yellow to red— to illustrate the duration of each step. This helps provide a smooth transition between each action.
As to begin setting up the code with the ‘millis’ function, I did not include LEDs within the circuit and had each panel light up for only 0.5 seconds. The following image shows the code used and denotes the function of each line:
The above code continued to integrate all five backlights within the circuit. With the use of the sensor, the WashBoard was activated when the IR break beam was restored and turned off when the beam was broken. The video below shows the above commands in action:
Having gotten a sense of how the ‘millis’ function operates, I began to now incorporate the LEDs. Initially, I planned on using the 12mm Diffused Flat Digital RGB LED Pixels ordered from adafruit. Coding for these LEDs proved to be a challenge. I started by attempting to rewire the string of lights to have only five operate (I only need one LED per panel, hence five LEDs in total). Additionally, I attempted to write a code that would allow me to change the colour of each LED over time periods associated with each panel. This task was extremely challenging and proved to take up a lot of my time. Given the deadline of our final projects, it was clear that I wouldn’t be able to complete the assignment had I tried to work with the Flat Digital LED lights. Therefore, I decided to use standard 5mm LEDs instead.
Since these LEDs are only capable of lighting a specific colour I would have to include three LEDs (one red, yellow and green) on the side of each panel. Such a setup would prove to increase the number of pins and wires required— an opportunity cost leading to a heavier WashBoard model. Overall the inclusion of three LEDs per panel seemed redundant, therefore I decided to have one green, yellow and red set of LEDs at the top of the board. This set of LEDs will illuminate according to each panel’s duration and serve as a mini ‘clock’ for the whole board.
To program such functions I included an ‘if’ statement within the ‘millis’ function. This sub ‘if’ statement referred to each LED and allowed me to manipulate the illumination durations of each LED through a delay function. The following image shows the code used and denotes the function of each line:
The above lines of code were then rewritten for each panel.
Having observed children washing their hands from videos and consulting Prof. Gleason, I came up with timings for each step and accounted for them within the program. The timings were as follows:
1) Wet hands (Text displayed: “Wet Hands”) ~ 5 secs
– Green LED on for 3 secs (begin action)
– Yellow LED on for 1.5 secs (midst action)
– Red LED on for 0.5 sces (end action)
2) Squirt soap onto hands ( Text displayed: “Soap”) ~ 7 secs
– Green LED on for 4 secs (begin action)
– Yellow LED on for 2.5 secs (midst action)
– Red LED on for 0.5 sces (end action)
3) Scrub hands with soap (Text displayed: “Scrub”) ~ 20 secs
– Green LED on for 10 secs (begin action)
– Yellow LED on for 9.5 secs (midst action)
– Red LED on for 0.5 sces (end action)
4) Wash soap off hands (Text displayed: “Rise Hands”) ~ 6 secs
– Green LED on for 3 secs (begin action)
– Yellow LED on for 2.5 secs (midst action)
– Red LED on for 0.5 sces (end action)
5) Turn off tap (Text displayed: “Turn tap off”) ~ 7 secs
– Green LED on for 3 secs (begin action)
– Yellow LED on for 2.5 secs (midst action)
– Red LED on for 0.5 sces (end action)
The video below shows WashBoard enact the above commands for panels 1, 2 and 3:
Designing the Device
Having completed the code for the WashBoard, I began to design its set up. I decided to use plywood for the backboard of the device and have a foam core skeleton around each backlight. This ‘skeleton’ would serve to cover the wires connected to the backlights and provide a succinct frame for each instruction.
Using solid works, I designed and laser cut the backboard and foam core frame. Images below show the solid works mock-ups.
Dimensions of the frame and backboard were made keeping the size and number of backlights in mind.
Following this, I screwed the Arduino and stuck the breadboard and battery pack on the back of the WashBoard. Having drilled holes at on the sides of the backboard, I was able to solder wires to the legs of the backlights. Similarly, I connected all other components on the backboard.
I then added a hook to the board and a support at the bottom to allow the sensor to stay above the sink. I also added a box to the back of the board to cover up all circuitry. The box has a slot to allow batteries to be replaced when necessary.
Final Demonstration and Reflection:
I think the demonstration of my final device was fairly successful. There didn’t seem to be any major concerns from Prof. Gleason. However, Sarah Barbrow (the science librarian) brought up the interesting concern of children who are colour blind being able to read the LED green, yellow and red lights at the top of the board. Overall, I don’t think this should be an issue, as the series of LEDs at the top of the board also make use of the left to right principle of reading. Additionally, the lighting up of each panel should make each instruction obvious to the child.
Although I had several issues when coding, I think I have been able to gain a deep understanding of the C++ language. Furthermore, I have been able to practice my soldering, drilling and laser cutting skills when designing and putting together the final product.
Wow, your product looks really close to finished! Your demonstration definitely went well, and seeing your documentation of the case for everything you were talking about definitely sheds light on your vision for the final product.
You did a really great job at going through multiple visions of your end product while explaining your thoughtful reasons for change. It was very easy to follow your design process and I think your end product was a very successful combination of your best ideas!