{"id":15281,"date":"2022-03-16T01:17:20","date_gmt":"2022-03-16T05:17:20","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/?p=15281"},"modified":"2022-03-16T01:17:20","modified_gmt":"2022-03-16T05:17:20","slug":"project-2-water-spray-alarm-clock","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/project-2-water-spray-alarm-clock\/","title":{"rendered":"Project 2: Water-spray alarm clock"},"content":{"rendered":"<h1>Water-spray Alarm Clock<\/h1>\n<p>A servo-activated alarm clock that instantly wakes you up by spraying water.<\/p>\n<p>&nbsp;<\/p>\n<h2>Images<\/h2>\n<div style=\"width: 620px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-15281-1\" width=\"620\" height=\"1102\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/VID_20220301_221957_Trim-1-1-1.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/VID_20220301_221957_Trim-1-1-1.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/VID_20220301_221957_Trim-1-1-1.mp4<\/a><\/video><\/div>\n<p>Short clip of alarm clock<\/p>\n<div id=\"attachment_15304\" style=\"width: 2429px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15304\" loading=\"lazy\" class=\"wp-image-15304 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3166-scaled-e1647279218734.jpg\" alt=\"\" width=\"2419\" height=\"1708\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3166-scaled-e1647279218734.jpg 2419w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3166-scaled-e1647279218734-300x212.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3166-scaled-e1647279218734-1024x723.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3166-scaled-e1647279218734-768x542.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3166-scaled-e1647279218734-1536x1085.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3166-scaled-e1647279218734-2048x1446.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3166-scaled-e1647279218734-973x687.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3166-scaled-e1647279218734-508x359.jpg 508w\" sizes=\"(max-width: 2419px) 100vw, 2419px\" \/><p id=\"caption-attachment-15304\" class=\"wp-caption-text\">Close up shot of the alarm clock<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15306\" style=\"width: 1718px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15306\" loading=\"lazy\" class=\"wp-image-15306 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3157-scaled-e1647279439457.jpg\" alt=\"\" width=\"1708\" height=\"1798\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3157-scaled-e1647279439457.jpg 1708w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3157-scaled-e1647279439457-285x300.jpg 285w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3157-scaled-e1647279439457-973x1024.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3157-scaled-e1647279439457-768x808.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3157-scaled-e1647279439457-1459x1536.jpg 1459w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3157-scaled-e1647279439457-508x535.jpg 508w\" sizes=\"(max-width: 1708px) 100vw, 1708px\" \/><p id=\"caption-attachment-15306\" class=\"wp-caption-text\">Top-view of input alarm<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15305\" style=\"width: 1776px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15305\" loading=\"lazy\" class=\"wp-image-15305 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3161-scaled-e1647279315822.jpg\" alt=\"\" width=\"1766\" height=\"1465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3161-scaled-e1647279315822.jpg 1766w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3161-scaled-e1647279315822-300x249.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3161-scaled-e1647279315822-1024x849.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3161-scaled-e1647279315822-768x637.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3161-scaled-e1647279315822-1536x1274.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3161-scaled-e1647279315822-973x807.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3161-scaled-e1647279315822-508x421.jpg 508w\" sizes=\"(max-width: 1766px) 100vw, 1766px\" \/><p id=\"caption-attachment-15305\" class=\"wp-caption-text\">Front view of input alarm<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15307\" style=\"width: 2179px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15307\" loading=\"lazy\" class=\"wp-image-15307 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3171-scaled-e1647279540154.jpg\" alt=\"\" width=\"2169\" height=\"1708\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3171-scaled-e1647279540154.jpg 2169w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3171-scaled-e1647279540154-300x236.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3171-scaled-e1647279540154-1024x806.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3171-scaled-e1647279540154-768x605.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3171-scaled-e1647279540154-1536x1210.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3171-scaled-e1647279540154-2048x1613.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3171-scaled-e1647279540154-973x766.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3171-scaled-e1647279540154-508x400.jpg 508w\" sizes=\"(max-width: 2169px) 100vw, 2169px\" \/><p id=\"caption-attachment-15307\" class=\"wp-caption-text\">Close up of trigger mechanism<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15292\" style=\"width: 1686px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15292\" loading=\"lazy\" class=\"wp-image-15292 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220301_185307-scaled-e1647269713513.jpg\" alt=\"\" width=\"1676\" height=\"1043\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220301_185307-scaled-e1647269713513.jpg 1676w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220301_185307-scaled-e1647269713513-300x187.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220301_185307-scaled-e1647269713513-1024x637.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220301_185307-scaled-e1647269713513-768x478.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220301_185307-scaled-e1647269713513-1536x956.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220301_185307-scaled-e1647269713513-973x606.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220301_185307-scaled-e1647269713513-508x316.jpg 508w\" sizes=\"(max-width: 1676px) 100vw, 1676px\" \/><p id=\"caption-attachment-15292\" class=\"wp-caption-text\">The insides of the box which contains all the other parts.<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15290\" style=\"width: 931px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15290\" loading=\"lazy\" class=\"wp-image-15290 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220222_213012-scaled-e1647269916339.jpg\" alt=\"\" width=\"921\" height=\"876\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220222_213012-scaled-e1647269916339.jpg 921w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220222_213012-scaled-e1647269916339-300x285.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220222_213012-scaled-e1647269916339-768x730.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_20220222_213012-scaled-e1647269916339-508x483.jpg 508w\" sizes=\"(max-width: 921px) 100vw, 921px\" \/><p id=\"caption-attachment-15290\" class=\"wp-caption-text\">The RTC module was instrumental in keeping track of time<\/p><\/div>\n<h2>Decision Points<\/h2>\n<ol>\n<li>\n<h3>Switching the servo&#8217;s position<\/h3>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15550\" style=\"width: 986px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15550\" loading=\"lazy\" class=\"wp-image-15550 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/85299.jpg\" alt=\"\" width=\"976\" height=\"737\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/85299.jpg 976w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/85299-300x227.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/85299-768x580.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/85299-973x735.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/85299-508x384.jpg 508w\" sizes=\"(max-width: 976px) 100vw, 976px\" \/><p id=\"caption-attachment-15550\" class=\"wp-caption-text\">Initial design to place Servo in front of trigger<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15556\" style=\"width: 630px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15556\" loading=\"lazy\" class=\"wp-image-15556 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3173-1024x683.jpg\" alt=\"\" width=\"620\" height=\"414\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3173-1024x683.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3173-300x200.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3173-768x512.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3173-1536x1024.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3173-2048x1365.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3173-973x649.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3173-508x339.jpg 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-15556\" class=\"wp-caption-text\">Final position for Servo behind bottle that pulls the trigger<\/p><\/div>\n<p>Initially, I envisioned the servo to trigger the water spray by pushing against the trigger from the front. This was conceptualized based on a previous project along the same lines. This was not feasible as I could not create a practical build where the servo provides sufficient force to trigger the water spray. However, through the guidance of the professor, he suggested to change the servo&#8217;s position to back of the water spray for a pulling mechanism which would be more efficient in triggering the water spray. This change in design ensured that proper functioning of my project!<\/li>\n<li>\n<h3>Creating a separate build for the arduino, LCD and rotary encoders<\/h3>\n<div id=\"attachment_15552\" style=\"width: 948px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15552\" loading=\"lazy\" class=\"wp-image-15552 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/84922.jpg\" alt=\"\" width=\"938\" height=\"768\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/84922.jpg 938w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/84922-300x246.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/84922-768x629.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/84922-508x416.jpg 508w\" sizes=\"(max-width: 938px) 100vw, 938px\" \/><p id=\"caption-attachment-15552\" class=\"wp-caption-text\">Initial design to build all hardware on water spray<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_15559\" style=\"width: 2442px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15559\" loading=\"lazy\" class=\"wp-image-15559 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3170-scaled-e1647407661863.jpg\" alt=\"\" width=\"2432\" height=\"1708\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3170-scaled-e1647407661863.jpg 2432w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3170-scaled-e1647407661863-300x211.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3170-scaled-e1647407661863-1024x719.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3170-scaled-e1647407661863-768x539.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3170-scaled-e1647407661863-1536x1079.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3170-scaled-e1647407661863-2048x1438.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3170-scaled-e1647407661863-973x683.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/DSC_3170-scaled-e1647407661863-508x357.jpg 508w\" sizes=\"(max-width: 2432px) 100vw, 2432px\" \/><p id=\"caption-attachment-15559\" class=\"wp-caption-text\">Final design with separate box for ardunio and other wiring.<\/p><\/div>\n<p>My original design aspired for the alarm clock to be as compact as possible. As seen in my sketch, I wanted all the hardwares to be mounted on the water spray so it could occupy the least space on my side table. My initial trials were futile as I tried to tape and super glue the arduino and LCD display on the water spray with a box that covers it. This was potentially practical when the servo motor was at the front of the water spray. However, the servo motor required a base behind the water spray which meant none of these designs could be accomplished. So, I used laser cutting to create a separate box that included all my other hardware. Nevertheless, this change appeared to be most practical and visually appealing.<\/li>\n<\/ol>\n<h2>Critiques<\/h2>\n<p><em>&#8220;<span style=\"font-weight: 400\">Such a useful device that definitely wakes me up.&#8221;<\/span><\/em><\/p>\n<p>This was definitely my intention, as a person who frequently misses their morning alarms, I wanted to create a device that wakes me up in the first go. Though the mist is quite refreshing in the first spray, it gets annoying when it triggers multiple times when the alarm rings!<\/p>\n<p><em>&#8220;<\/em><em><span style=\"font-weight: 400\">Do you like to sleep with wet pillows?&#8221;<\/span><\/em><\/p>\n<p>This was something I did not consider! I did not foresee that it would make my bed wet after it sprays a number of times. Thankfully, the water spray only sprays mist as compared to water droplets which mitigates this issue. However, I would have to find waterproof bedding now onwards.<\/p>\n<h2>Discussion<\/h2>\n<p>I was extremely delighted when I first saw the water spray being triggered by the servo based on the alarm time. It met the basic functionality that I had originally envisioned. I couldn&#8217;t wait to try it out in my room when it worked in the physical computing lab. The first few tests seemed to work perfectly but it filled me with dread upon realising that it would ruin my mornings if it disrupted my dreams or sleep cycles.<\/p>\n<p>This project provided insights into the process of designing and building prototypes which I have never done before in my life. The structured delivery timeline ensured I was on time for all my deliverables while providing incentive to work ahead of the deadline. There were times where I was at the end of my wits when the servo did not trigger as expected. During the process, I found myself stuck in a particular way of thinking which limits my creativity and in this case, without the help of the professor, I would not have been able to overcome it. It emphasized the importance of having some degree of flexibility from the design of the prototype in the actual implementation as we cannot foresee everything from the get-go.<\/p>\n<p>After finishing the project, I planned to 3D print a build that accomodates everything on the water spray but eventually dropped the idea to focus on other upcoming deliverables. I would try to create a build with a smaller base for the servo motor using other alternates besides styrofoam. Additionally, would try to find a way to screw the servo into the water spray or the base to ensure that it does not come off loose as the current project is hot glued together and might come off after frequent number of triggers. I would incorporate other design changes such as adding a snooze function which is not a simple switch at the top, add a water level sensor to remind the user when the bottle is empty.<\/p>\n<h2>Schematic and block diagrams<\/h2>\n<div id=\"attachment_15309\" style=\"width: 837px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15309\" loading=\"lazy\" class=\"wp-image-15309 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-2-1.jpg\" alt=\"\" width=\"827\" height=\"401\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-2-1.jpg 827w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-2-1-300x145.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-2-1-768x372.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-2-1-508x246.jpg 508w\" sizes=\"(max-width: 827px) 100vw, 827px\" \/><p id=\"caption-attachment-15309\" class=\"wp-caption-text\">Block diagram<\/p><\/div>\n<div id=\"attachment_15308\" style=\"width: 1111px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-15308\" loading=\"lazy\" class=\"wp-image-15308 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-1.jpg\" alt=\"\" width=\"1101\" height=\"795\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-1.jpg 1101w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-1-300x217.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-1-1024x739.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-1-768x555.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-1-973x703.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/Untitled-Diagram-1-508x367.jpg 508w\" sizes=\"(max-width: 1101px) 100vw, 1101px\" \/><p id=\"caption-attachment-15308\" class=\"wp-caption-text\">Schematic<\/p><\/div>\n<h2>Code<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/*\r\nProject Title: Water-spray Alarm Clock\r\nName: Siddharth Parthiban\r\nDescription: User sets the time for the alarm by rotating the two rotary encoders whereby controlling the hours and the minutes which is displayed by the LCD Screen. The RTC module provides the input for the current time and when both the alarm and the current time is the same, the code directs the servo to rotates 40 degrees back and forth to trigger the water spray. Additionally, as a snooze button, the switch controls whether the water spray is triggered multiple times during the alarm duration. \r\n\r\nPin Mapping:\r\n   Arduino pin | role    | description\r\n   ------------|---------|-------------\r\n   2             input     rotary encoder(hour) pin A\r\n   3             input     rotary encoder(hour) pin B\r\n   5             input     rotary encoder(min) pin A\r\n   6             input     rotary encoder(min) pin B\r\n   8             output    Servo motor\r\n   10            input     switch \r\n   SCL           input     RTC Module\/LCD\r\n   SDA           input     RTC Module\/LCD\r\n\r\nRotary Encoder Code adapted from https:\/\/dronebotworkshop.com\/rotary-encoders-arduino\/#Arduino_Motor_Encoder_Sketch DroneBot Workshop 2019\r\n*\/\r\n\r\n#include &lt;Encoder.h&gt;\r\n#include &lt;Servo.h&gt;\r\n#include &lt;LiquidCrystal_I2C.h&gt;\r\n#include &lt;Wire.h&gt;\r\n#include &lt;DS3232RTC.h&gt;\r\n\r\n\/\/Initialising variables for user input\r\nlong rotatMin = 0;\r\nlong prevRotatMin = -999;\r\nint alarmMinute;\r\nint alarmHour;\r\nint curMinute;\r\nint curHour;\r\nlong rotatHour = 0;\r\nlong prevRotatHour= -999;\r\n\r\n\/\/Initialising variable for output\r\nint servoDegree = 20;\r\nfloat oldTimeDisplay  = 0;\r\n\r\n\/\/Initialising pin ports for Arduino\r\nint\u00a0SWITCHPIN\u00a0=\u00a010;\r\nconst int SERVOMOTORPIN = 8;\r\n\r\n\/\/Creating Servo, Rotary Encoder and RTC module objects\r\nServo servoMotor;\u00a0\r\nEncoder hourEncod(2,3);\r\nEncoder minEncod(5,6);\r\nDS3232RTC myRTC;\r\n\r\n\/\/Declaring LCD screen object\r\nLiquidCrystal_I2C screen(0x27, 16, 2);\r\n\r\nvoid setup() {\r\n  Serial.begin(9600); \/\/setting data rate\r\n  pinMode(SWITCHPIN, INPUT); \/\/declaring switch for arduino\r\n  \r\n  \/\/Setting up servo motor\r\n  servoMotor.attach(SERVOMOTORPIN);\r\n  servoMotor.write(servoDegree);  \r\n  \r\n  \/\/Setting up LCD Screen\r\n  screen.init();\r\n  screen.backlight();\r\n  screen.home();  \r\n}\r\n\r\n\r\nvoid loop() {\r\n  time_t t = myRTC.get(); \/\/Get current time\r\n  \r\n  \/\/Read user input from rotary encoder\r\n  rotatMin = minEncod.read();\r\n  rotatHour = hourEncod.read();\r\n\r\n  \/\/Calculate the minutes based on rotations\r\n  if (rotatMin != prevRotatMin){\r\n    prevRotatMin = rotatMin;\r\n\r\n \/\/Rotations divided by 4 to set an arbitrary unit for 1 turn of the knob\r\n \/\/Modulo 60 to get convert turns to respective minutes\r\n \/\/if-else statements to consider anti-clockwise turns\r\n    if (rotatMin &lt; 0){\r\n      alarmMinute = (-(rotatMin\/4)) % 60; \r\n    } else {\r\n      alarmMinute =  (rotatMin\/4) % 60; \r\n    }\r\n    \r\n    \/\/Display set minutes to LCD Screen\r\n    screen.setCursor(12,1);\r\n    screen.print((String)alarmMinute);\r\n  }\r\n\r\n\/\/Calculate hour based on rotations\r\n  if (rotatHour != prevRotatHour){\r\n    prevRotatHour = rotatHour;\r\n\r\n\/\/Rotations divided by 4 to set an arbitrary unit for 1 turn of the knob\r\n\/\/Modulo 24 to get convert turns to respective hour\r\n\/\/if-else statements to consider anti-clockwise turns\r\n    if (rotatHour &lt; 0){\r\n      alarmHour = (-(rotatHour)\/4) % 24;\r\n    } else {\r\n      alarmHour = (rotatHour\/4) % 24;\r\n    }\r\n    \r\n    \/\/Display hour on LCD Screen\r\n    screen.setCursor(9,1);\r\n    screen.print((String)alarmHour + \":\");\r\n  }\r\n\r\n\/\/Move servo motor if not on snooze to trigger water spray\r\n  if (digitalRead(SWITCHPIN) == 0){\r\n    \r\n    \/\/Check if current time is equal to alarm time\r\n    if (minute(t) == alarmMinute &amp;&amp; hour(t) == alarmHour){\r\n      servoMotor.write(servoDegree + 90);\r\n      delay(500);\r\n      servoMotor.write(servoDegree - 50);   \r\n      delay(1000); \r\n      servoMotor.write(servoDegree + 90);\r\n      delay(500);\r\n      servoMotor.write(servoDegree - 50); \r\n    }\r\n  }\r\n    \/\/Reset servo motor to neutral position\r\n    servoDegree = 20;\r\n    servoMotor.write(servoDegree);\r\n\r\n\/\/Display values to LCD Screen\r\n  if (millis() - oldTimeDisplay &gt;= 250) {\r\n    oldTimeDisplay = millis();\r\n    screen.clear();\r\n    screen.setCursor(2, 0);\r\n    screen.print(\"Time\");\r\n    screen.setCursor(2, 1);\r\n    screen.print((String)hour(t)+ \":\" +(String) minute(t));\r\n    screen.setCursor(8, 0);\r\n    screen.print(\"Alarm\");\r\n    screen.setCursor(9, 1);\r\n    screen.print((String)alarmHour + \":\" + (String) alarmMinute);\r\n\r\n  }\r\n}\r\n  \r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Water-spray Alarm Clock A servo-activated alarm clock that instantly wakes you up by spraying water. &nbsp; Images Short clip of alarm clock &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Decision&#8230;<\/p>\n","protected":false},"author":207,"featured_media":15303,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[89],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15281"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/users\/207"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/comments?post=15281"}],"version-history":[{"count":6,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15281\/revisions"}],"predecessor-version":[{"id":15563,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15281\/revisions\/15563"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media\/15303"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media?parent=15281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/categories?post=15281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/tags?post=15281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}