{"id":17583,"date":"2023-03-05T16:03:27","date_gmt":"2023-03-05T21:03:27","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/?p=17583"},"modified":"2023-03-05T16:04:35","modified_gmt":"2023-03-05T21:04:35","slug":"morning-insurance","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/morning-insurance\/","title":{"rendered":"Morning Insurance"},"content":{"rendered":"<p>By Andres Montemayor<\/p>\n<p>A non-destructive attachment to a campus bed that includes a clock, alarm, shelf, and lockable compartment to prevent use of phone in bed.<\/p>\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-17583-1\" width=\"620\" height=\"1102\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/clock_alarm-clock-in-use.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/clock_alarm-clock-in-use.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/clock_alarm-clock-in-use.mp4<\/a><\/video><\/div>\n<p style=\"text-align: center\"><em>Demonstration of Alarm\/Clock Functionality of Project. Here the alarm would have been set and when the time and alarm where the same, the buzzer would have started.<\/em><\/p>\n<div style=\"width: 620px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-17583-2\" width=\"620\" height=\"1102\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/solenoid-in-use.mp4?_=2\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/solenoid-in-use.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/solenoid-in-use.mp4<\/a><\/video><\/div>\n<p style=\"text-align: center\"><i>Demonstration of use of solenoid lock in bottom compartment of project. Here the compartment would be closed and the button far away from bed, forcing user to stand up and walk to press button and unlock compartment in order to access phone.<\/i><\/p>\n<div id=\"attachment_17586\" style=\"width: 3034px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/morning-insurance\/feature-image-morning-insurance\/\" rel=\"attachment wp-att-17586\"><img aria-describedby=\"caption-attachment-17586\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-17586\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/feature-Image-morning-insurance.png\" alt=\"Wooden box with a LCD display, two potentiometers, a locked compartment on the bottom, and two buttons. One on the box to light up LCD screen and another to open compartment.\" width=\"3024\" height=\"4032\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/feature-Image-morning-insurance.png 3024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/feature-Image-morning-insurance-225x300.png 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/feature-Image-morning-insurance-768x1024.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/feature-Image-morning-insurance-1152x1536.png 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/feature-Image-morning-insurance-1536x2048.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/feature-Image-morning-insurance-973x1297.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/feature-Image-morning-insurance-508x677.png 508w\" sizes=\"(max-width: 3024px) 100vw, 3024px\" \/><\/a><p id=\"caption-attachment-17586\" class=\"wp-caption-text\">Overall photo of the developed product for proportion and scale<\/p><\/div>\n<div id=\"attachment_17599\" style=\"width: 3530px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/morning-insurance\/lcd-display-potentiometers\/\" rel=\"attachment wp-att-17599\"><img aria-describedby=\"caption-attachment-17599\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-17599\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/LCD-display-potentiometers.png\" alt=\"Two potentiometers and a 16x2 LCD screen that clearly displays current time and when alarm is set for\" width=\"3520\" height=\"1980\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/LCD-display-potentiometers.png 3520w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/LCD-display-potentiometers-300x169.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/LCD-display-potentiometers-1024x576.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/LCD-display-potentiometers-768x432.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/LCD-display-potentiometers-1536x864.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/LCD-display-potentiometers-2048x1152.png 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/LCD-display-potentiometers-973x547.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/LCD-display-potentiometers-508x286.png 508w\" sizes=\"(max-width: 3520px) 100vw, 3520px\" \/><\/a><p id=\"caption-attachment-17599\" class=\"wp-caption-text\">Clear visual of layout of current time and alarm set point. Also location of potentiometers to set alarm.<\/p><\/div>\n<div id=\"attachment_17600\" style=\"width: 4042px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/morning-insurance\/compartment-and-solenoid-lock\/\" rel=\"attachment wp-att-17600\"><img aria-describedby=\"caption-attachment-17600\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-17600 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/compartment-and-solenoid-lock.png\" alt=\"Open bottom compartment to lock phone and solenoid lock attached to right side wall.\" width=\"4032\" height=\"3024\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/compartment-and-solenoid-lock.png 4032w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/compartment-and-solenoid-lock-300x225.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/compartment-and-solenoid-lock-1024x768.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/compartment-and-solenoid-lock-768x576.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/compartment-and-solenoid-lock-1536x1152.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/compartment-and-solenoid-lock-2048x1536.png 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/compartment-and-solenoid-lock-973x730.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/compartment-and-solenoid-lock-508x381.png 508w\" sizes=\"(max-width: 4032px) 100vw, 4032px\" \/><\/a><p id=\"caption-attachment-17600\" class=\"wp-caption-text\">Open space to place phone to prevent use, sliding door to access the space and the 5V solenoid lock controlled by button that is separate from main system.<\/p><\/div>\n<h2>Process Images and Review<\/h2>\n<p>Throughout the design and production process of this project, there were a couple decision points that impacted the final design of my project. The first and most notable was the mode of triggering the solenoid to unlock. Due to wanting to include other subsystems within the final design, as well as manufacturing time requirements, I had to opt for a simpler mode of unlocking the solenoid lock. Originally, I was planning on creating a switch connected to a NRF24L01 wireless connector and a battery source placed in another room that &#8216;spoke&#8217; to another NRF connector in the main system that told the solenoid lock to open. However, using this to operate the system would have required ordering the part, learning how to get two Arduinos to communicate correctly and I&#8217;m sure other issues not considered. Instead, as can be seen in the below image, I used a simple arcade pushbutton connected to the singular Arduino in the product connected through two wires that could be placed at a distance from the bed due to the length of those wires. This decision gave me the time to properly code, wire, and build the other parts of the project instead of struggling with a single subsystem.<\/p>\n<div id=\"attachment_17602\" style=\"width: 1503px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/morning-insurance\/button\/\" rel=\"attachment wp-att-17602\"><img aria-describedby=\"caption-attachment-17602\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-17602\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/button.png\" alt=\"Red pushbutton mounted on a wooden mount with wires coming out from the side\" width=\"1493\" height=\"929\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/button.png 1493w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/button-300x187.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/button-1024x637.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/button-768x478.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/button-973x605.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/button-508x316.png 508w\" sizes=\"(max-width: 1493px) 100vw, 1493px\" \/><\/a><p id=\"caption-attachment-17602\" class=\"wp-caption-text\">Trigger push button used to open solenoid rather than a wireless connection<\/p><\/div>\n<p>Another point that I had to think about and change that significantly impacted the design of my project was the type of speaker to use in the alarm system itself. Originally, I was going to not even use a speaker at all but instead use a vibrator pancake available in the physical computing lab, however, after testing it, I realized that unless I had it physically on my body somehow it would be insufficient to wake me up in the morning. Then I decided to use a 8\u03a9, 0.2W speaker as that was what I was familiar with from project 1. However, I had a lot of problems with this as I would run 5 V through this speaker when it was not designed for this amount of power. This meant that even though my wiring was correct, the speaker would stop working after a couple of uses of the system. I fixed this issue by using a 8\u03a9, 3W speaker and a transistor to convey the alarm sound. This speaker could accept the 5V without issue and allowed my alarm to work without issue.<\/p>\n<h3>Process Images<\/h3>\n<div id=\"attachment_17604\" style=\"width: 1538px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/morning-insurance\/cad-diagram-of-project\/\" rel=\"attachment wp-att-17604\"><img aria-describedby=\"caption-attachment-17604\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-17604\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/cad-diagram-of-project.png\" alt=\"Computer Aided Design of project casing\" width=\"1528\" height=\"792\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/cad-diagram-of-project.png 1528w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/cad-diagram-of-project-300x155.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/cad-diagram-of-project-1024x531.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/cad-diagram-of-project-768x398.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/cad-diagram-of-project-973x504.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/cad-diagram-of-project-508x263.png 508w\" sizes=\"(max-width: 1528px) 100vw, 1528px\" \/><\/a><p id=\"caption-attachment-17604\" class=\"wp-caption-text\">Solidworks design of project to be laser-cut out of wood. Used finger joints and glue to attach after cut.<\/p><\/div>\n<div id=\"attachment_17607\" style=\"width: 1171px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/morning-insurance\/initial-breadboard-work\/\" rel=\"attachment wp-att-17607\"><img aria-describedby=\"caption-attachment-17607\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-17607\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/initial-breadboard-work.png\" alt=\"RTC module, speaker, Arduino, potentiometers, LCD Screen, and buttons connected through a breadboard\" width=\"1161\" height=\"1706\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/initial-breadboard-work.png 1161w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/initial-breadboard-work-204x300.png 204w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/initial-breadboard-work-697x1024.png 697w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/initial-breadboard-work-768x1129.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/initial-breadboard-work-1045x1536.png 1045w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/initial-breadboard-work-973x1430.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/initial-breadboard-work-508x746.png 508w\" sizes=\"(max-width: 1161px) 100vw, 1161px\" \/><\/a><p id=\"caption-attachment-17607\" class=\"wp-caption-text\">Initial prototyping of electronics to make sure code and electronics worked together correctly when using temporary connections before everything connecting through use of soldering.<\/p><\/div>\n<div id=\"attachment_17608\" style=\"width: 1228px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/morning-insurance\/turn-speaker-off\/\" rel=\"attachment wp-att-17608\"><img aria-describedby=\"caption-attachment-17608\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-17608\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/turn-speaker-off.png\" alt=\"Slice of code that shows how alarm speaker triggered and turned off\" width=\"1218\" height=\"346\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/turn-speaker-off.png 1218w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/turn-speaker-off-300x85.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/turn-speaker-off-1024x291.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/turn-speaker-off-768x218.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/turn-speaker-off-973x276.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/turn-speaker-off-508x144.png 508w\" sizes=\"(max-width: 1218px) 100vw, 1218px\" \/><\/a><p id=\"caption-attachment-17608\" class=\"wp-caption-text\">Code slice showing how speaker could be turned on or off. Was an issue at first because in original code alarm would not turn off after it had been triggered. Here, line 124 ensures that alarm only on at appropriate time.<\/p><\/div>\n<div id=\"attachment_17605\" style=\"width: 4042px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/morning-insurance\/sotered-electronics-in-project\/\" rel=\"attachment wp-att-17605\"><img aria-describedby=\"caption-attachment-17605\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-17605\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/sotered-electronics-in-project.png\" alt=\"Open box with wires running from Arduino to separate electronics\" width=\"4032\" height=\"3024\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/sotered-electronics-in-project.png 4032w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/sotered-electronics-in-project-300x225.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/sotered-electronics-in-project-1024x768.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/sotered-electronics-in-project-768x576.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/sotered-electronics-in-project-1536x1152.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/sotered-electronics-in-project-2048x1536.png 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/sotered-electronics-in-project-973x730.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/sotered-electronics-in-project-508x381.png 508w\" sizes=\"(max-width: 4032px) 100vw, 4032px\" \/><\/a><p id=\"caption-attachment-17605\" class=\"wp-caption-text\">Process of putting together final product. Included soldered together electronics, and Arduino. Later top of box glued down so no wires exposed unnecessarily.<\/p><\/div>\n<h2>Discussion<\/h2>\n<p>This was a very interesting project to work on, challenging on a technical level while still allowing growth of skills such as soldering, circuits and design. There were a couple of things I would have liked to change or improve on if I had more time to work on the project before submission. In fact, two of those were pointed on in the in-class critique. The first was, &#8220;<span style=\"font-weight: 400\">You could add some sort of long piece connected to the bottom that would go under the mattress instead of just attaching it to the side of the bed&#8221;. This was an issue I didn&#8217;t give sufficient thought to. I had planned to attach the developed system to my bed using command strips as seen in the featured image, however when I attempted that it did not work. Not providing enough support for when I placed my hand on it. I plan on creating a bar to extend from the bed frame that I can attach the bottom of the box to instead of using command strips. Another comment of interest was, &#8220;I wish the top was cushioned or padded with fabric in some way. Not sure how the wood texture would feel during sleep.&#8221; I want to put some cushioning on the free area of the object to rest my arm on in, to accomplish this I plan to buy a very small pillow and attach it to the wood using hooks.\u00a0<\/span><\/p>\n<p>Overall, I was satisfied with my project. it accomplished the goal I set out with, which was a bed attachment that I could rest my arm on when asleep, and in fact I added functionality to this initial problem such as a clock, alarm and phone lock to ensure I get up when I need to. The only thing I would want to spend more time on if I could is form. This is one thing I learned while working on this project. Don&#8217;t be committed to one design too early. Once I made my first CAD of the product, I immediately laser cut it out of the final material. However I think if I would have started making out of cardboard fr simpler faster manner I could have seen a lot of areas of improvement in advance. I also learned a lot about the use of transistor and their use. I think they really helped me refine my final electrical design. Making both the speaker and solenoid work a lot better as I could consistent voltage through them very easily in a very controlled manner that not using them would prevent. Finally, I do not plan on doing another iteration of this product but instead just doing a couple of easy improvements to my existing product to allow for better use. If I were to make another iteration though, there are three major things I would do. The first is wire management. I soldered all my cables in my product, however I often used soldered wires to get them off the protoboard when not necessary. I would be both easier and cleaner to place things directly on the board. Second is attachment mode, I would use an attachment rod on the bottom instead of command strips. Lastly, I would want to use a more complex way to unlock the solenoid lock. Instead of a simple push button I might use a computer generated math problem or something similar.<\/p>\n<h2>Technical Information<\/h2>\n<div id=\"attachment_17611\" style=\"width: 1047px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/morning-insurance\/block-diagramp2-drawio\/\" rel=\"attachment wp-att-17611\"><img aria-describedby=\"caption-attachment-17611\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-17611 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/Block-DiagramP2.drawio.svg\" alt=\"Block diagram of Morning Insurance project showing inputs, controller, and outputs\" width=\"1037\" height=\"592\" \/><\/a><p id=\"caption-attachment-17611\" class=\"wp-caption-text\">Block diagram of product showing inputs and outputs of system<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_17612\" style=\"width: 1241px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/morning-insurance\/pc-project-2-block-and-electrical-drawio-2\/\" rel=\"attachment wp-att-17612\"><img aria-describedby=\"caption-attachment-17612\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-17612 size-full\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-content\/uploads\/2023\/03\/PC-Project-2-block-and-electrical.drawio-2.svg\" alt=\"Electrical schematic showing how each subsystem is wired and connected to the Arduino. Includes each part, supplied power, ground and resisters used.\" width=\"1231\" height=\"912\" \/><\/a><p id=\"caption-attachment-17612\" class=\"wp-caption-text\">Electrical schematic of and how each system is attached to Arduino<\/p><\/div>\n<h2>Code<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/*\r\nMorning Insurance: Assistive Device for Yourself, Project 2\r\nBy: Andres Montemayor\r\n\r\nDescription: The code below does five seperate things.\r\nThe first would be to set the alarm. By reading two seperate potentiometer inputs, it maps their values\r\nonto a 24 hour time schedule and displays that alarm time on an I2C LCD module\r\nThe second is it reads the current time from an RTC module and also displays that on the I2C Module,\r\nThe third is it only turns on the backlight of a LCD screen for a predescribed length of time when button 1\r\nis pressed.\r\nThe fourth is it unlocks a solenoid for a predetermined length of time when button 2 is pressed.\r\nThe fifth is when the current hour and minute on the clock is equal to the hour and minute set in the alarm\r\nit triggers a speaker to make noise until that is no longer true. IE when the alarm changes or the minute\r\nchanges.\r\n\r\nPin Map:\r\npin        | mode   | description\r\n\r\nPOT1_PIN     | input        | potentiometer: sets alarm hour\r\nPOT2_PIN     | input        | potentiometer: sets alarm minute\r\nbuttonPin    | input        | reads when arcade button pressed, triggers backlight on LCD screen\r\nlockButton   | input        | reads when arcade button pressed, unlocks solenoid\r\nSPEAKER_PIN1 | output       | outputs sound at 400 Hz while alarm is triggered\r\nSOLE_PIN     | output       | unlocks door, high or low to control if open or closed\r\nSQL          | OUTPUT\/INPUT | lcd and rtc go in here\r\nSDA          | OUTPUT\/INPUT | lcd and rtc go in here\r\n\r\nCredit:\r\nUsed chatGPT to assist in writing code for controlling wheather or not the backlight should be on\r\nIE lines 99 through 111.\r\nUsed example code from course website for I2C lcd displays available at\r\nthis website:https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/tutorials\/I2C-lcd,\r\nand example code from RTC, ds3231, to help write relevent sections\r\nUsed library from adafruit on RTC_DS3231 available at this website:https:\/\/github.com\/adafruit\/RTClib\r\n*\/\r\n\r\n\r\n\/\/modules to control different subsystems\r\n#include &lt;Wire.h&gt;\r\n#include &lt;LiquidCrystal_I2C.h&gt;\r\n#include &lt;RTClib.h&gt;\r\n\r\n\/\/Initialize the LCD library with the I2C address, number of columns and rows. call it lcd\r\nLiquidCrystal_I2C lcd(0x27, 16, 2);\r\n\r\n\/\/ Initialize the RTC module object and call it rtc to control from now on\r\nRTC_DS3231 rtc;  \r\n\r\n\/\/ Initialize the pins for the potentiometers, buttons, speaker, and solenoid\r\nconst int POT1_PIN = A0;\r\nconst int POT2_PIN = A1;\r\nconst int SPEAKER_PIN1 = 9;\r\nconst int buttonPin = 2;\r\nconst int lockButton = 5;\r\nconst int SOLE_PIN =11;\r\n\r\n\/\/Initialize variables used throughout code for time, timers, and bools\r\nbool isButtonPressed = false;\r\nbool isLightOn = false;\r\nbool isDoorOpen = false;\r\n\r\nint alarm_hour = 0;\r\nint alarm_minute = 0;\r\n\r\nunsigned long lastOnTime = 0;\r\nunsigned long lastUnlockTime = 0;\r\n\r\nvoid setup() {\r\n  \/\/ Initialize the LCD display\r\n  lcd.init();\r\n\r\n  \/\/ Initialize the RTC module\r\n  Wire.begin();\r\n  rtc.begin();\r\n\r\n  \/\/ Set the current time, only do if need to replace battery in RTC module.\r\n  \/\/rtc.adjust(DateTime(2023, 2, 27, 9, 50, 00));  \/\/year,month,day,hour,min,sec\r\n\r\n  \/\/ Set the pins for the potentiometers, vibrator, speaker and solenoid\r\n  pinMode(buttonPin, INPUT);\r\n  pinMode(POT1_PIN, INPUT);\r\n  pinMode(POT2_PIN, INPUT);\r\n  pinMode(SPEAKER_PIN1, OUTPUT);\r\n  pinMode(lockButton,INPUT);\r\n  pinMode(SOLE_PIN,OUTPUT);\r\n}\r\n\r\nvoid loop() {\r\n  \/\/if button pressed open solenoid and start a timer\r\n  if (digitalRead(lockButton) == LOW) {\r\n    lastUnlockTime = millis();\r\n    isDoorOpen = true;\r\n    digitalWrite(SOLE_PIN,HIGH);\r\n  }\r\n  \/\/if 15 seconds have passed close solenoid\r\n  if (millis()-lastUnlockTime &gt;= 15000) {\r\n    digitalWrite(SOLE_PIN,LOW);\r\n  }\r\n  \/\/if button pressed and backlight off, turn it on and start a timer\r\n  if (digitalRead(buttonPin) == LOW &amp;&amp; !isLightOn) {\r\n    isButtonPressed = true;\r\n    lastOnTime = millis();\r\n    lcd.backlight();\r\n    isLightOn = true;\r\n  }\r\n\r\n  \/\/ Check if the LCD screen is on and the timer is off\r\n  if (isButtonPressed &amp;&amp; (millis() - lastOnTime) &gt;= 20000) {\r\n    lcd.noBacklight();\r\n    isButtonPressed = false;\r\n    isLightOn = false;\r\n  }\r\n\r\n  \/\/ Print the current time to the LCD display\r\n  DateTime now = rtc.now();\r\n  lcd.setCursor(0, 0);\r\n  lcd.print(now.hour(), DEC);\r\n  lcd.print(\":\");\r\n  if (now.minute() &lt; 10) {\r\n    lcd.print(\"0\");\r\n  }\r\n  lcd.print(now.minute(), DEC);\r\n  lcd.print(\":\");\r\n  if (now.second() &lt; 10) {\r\n    lcd.print(\"0\");\r\n  }\r\n  lcd.print(now.second(), DEC);\r\n\r\n  \/\/ Read the values of the potentiometers to set the alarm\r\n  int pot1_value = analogRead(POT1_PIN);\r\n  int pot2_value = analogRead(POT2_PIN);\r\n  alarm_hour = map(pot1_value, 0, 1023, 0, 23);\r\n  alarm_minute = map(pot2_value, 0, 1023, 0, 59);\r\n\r\n  \/\/ Print the alarm time to the LCD display\r\n  lcd.setCursor(0, 1);\r\n  lcd.print(\"Alarm: \");\r\n  if (alarm_hour &lt; 10) {\r\n    lcd.print(\"0\");\r\n  }\r\n  lcd.print(alarm_hour);\r\n  lcd.print(\":\");\r\n  if (alarm_minute &lt; 10) {\r\n    lcd.print(\"0\");\r\n  }\r\n  lcd.print(alarm_minute);\r\n\r\n  \/\/ Check if the current time matches the alarm time\r\n  if (now.hour() == alarm_hour &amp;&amp; now.minute() == alarm_minute) {\r\n    \/\/ Activate the speaker\r\n    tone(SPEAKER_PIN1, 440, 0);\r\n  }\r\n  else {\r\n    \/\/otherwise turn off speaker\r\n    noTone(SPEAKER_PIN1);\r\n  }\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By Andres Montemayor A non-destructive attachment to a campus bed that includes a clock, alarm, shelf, and lockable compartment to prevent use of phone in bed. Demonstration of&#8230;<\/p>\n","protected":false},"author":37,"featured_media":17586,"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\/s2023\/work\/wp-json\/wp\/v2\/posts\/17583"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/users\/37"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/comments?post=17583"}],"version-history":[{"count":18,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/posts\/17583\/revisions"}],"predecessor-version":[{"id":17616,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/posts\/17583\/revisions\/17616"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/media\/17586"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/media?parent=17583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/categories?post=17583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2023\/work\/wp-json\/wp\/v2\/tags?post=17583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}