{"id":5903,"date":"2021-06-22T11:07:42","date_gmt":"2021-06-22T18:07:42","guid":{"rendered":"https:\/\/www.circuitspecialists.com\/blog\/?p=5903"},"modified":"2022-07-29T10:13:11","modified_gmt":"2022-07-29T17:13:11","slug":"the-smart-house-project-part-4","status":"publish","type":"post","link":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/","title":{"rendered":"The Smart House Project \u2013 Part 4"},"content":{"rendered":"\n<p><a href=\"\/blog\/the-smart-house-project-part-3\/\">The Smart House Project <\/a>is almost at the final stage, so let&#8217;s do a recap on everything we have done so far. We have installed a LED lighting system that reacts to the outdoor light level to offer personal lighting inside. Next, we want to make sure the house has a modern security system, which means receiving live sensor data and reacting accordingly. The light sensor for the LED lighting system could also be integrated into the security system, such that the current light level would somewhat affect the security sensitivity. Last but not least, the Air Conditioning Unit System receives outdoor temperature as a factor of control. The goal is to lower the power consumption by recognizing the outdoor temperature and controlling the indoor accordingly. This system works even better when there is an option to just let the filter air in. Furthermore, the house can log this data for further analysis and ultimately integrate them into the Smart House Controlling System. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Final Chapter<\/h4>\n\n\n\n<p>In this final project, we will explore the true meaning of a 21st century smart home, where the house recognizes the occupants&#8217; vehicle and opens the garage door. This feature will help with a family that has a lot of young children, especially after a long day of work. The Smart House Controlling System will then greet them with their preferred source of information,&nbsp; check on a family member, get updates on the latest news, and check up on the to-do list.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Let build the garage door<\/h5>\n\n\n\n<p>Cut out the garage door.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2275-1-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2275-1-1024x768.jpg\" alt=\"\" class=\"wp-image-5907\" srcset=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2275-1-1024x768.jpg 1024w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2275-1-300x225.jpg 300w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2275-1-768x576.jpg 768w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2275-1-1536x1152.jpg 1536w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2275-1-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Cut out the slot for the servo.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2277-1-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2277-1-1024x768.jpg\" alt=\"\" class=\"wp-image-5909\" srcset=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2277-1-1024x768.jpg 1024w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2277-1-300x225.jpg 300w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2277-1-768x576.jpg 768w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2277-1-1536x1152.jpg 1536w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2277-1-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Dry fit to make sure the servo fit nicely.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2278-1-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2278-1-1024x768.jpg\" alt=\"\" class=\"wp-image-5912\" srcset=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2278-1-1024x768.jpg 1024w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2278-1-300x225.jpg 300w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2278-1-768x576.jpg 768w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2278-1-1536x1152.jpg 1536w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2278-1-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Test the servo before gluing it down to make sure the servo motor works.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><a href=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2280-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2280-1024x768.jpg\" alt=\"\" class=\"wp-image-5910\" width=\"782\" height=\"588\" srcset=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2280-1024x768.jpg 1024w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2280-300x225.jpg 300w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2280-768x576.jpg 768w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2280-1536x1152.jpg 1536w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2280-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 782px) 100vw, 782px\" \/><\/a><\/figure>\n\n\n\n<p>I will attach the schematic below for reference.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Schematic.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"726\" src=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Schematic-1024x726.png\" alt=\"\" class=\"wp-image-5929\" srcset=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Schematic-1024x726.png 1024w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Schematic-300x213.png 300w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Schematic-768x545.png 768w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Schematic.png 1115w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Make a linkage connection from the servo horn to the garage door and use tape as a hinge for the garage door. You can find more information about how to make a tape hinge here<a href=\"https:\/\/www.rcgroups.com\/forums\/showthread.php?2190562-Best-Hinge-Tape\"> https:\/\/www.rcgroups.com\/forums\/showthread.php?2190562-Best-Hinge-Tape<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><a href=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2281-scaled.jpg\"><img decoding=\"async\" src=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2281-edited.jpg\" alt=\"\" class=\"wp-image-5914\" width=\"765\" srcset=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2281-edited.jpg 1340w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2281-edited-300x226.jpg 300w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2281-edited-1024x770.jpg 1024w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2281-edited-768x578.jpg 768w\" sizes=\"(max-width: 1340px) 100vw, 1340px\" \/><\/a><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">This step is optional. <\/h5>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><a href=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2282-4-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2282-4-1024x768.jpg\" alt=\"\" class=\"wp-image-5923\" width=\"819\" height=\"614\" srcset=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2282-4-1024x768.jpg 1024w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2282-4-300x225.jpg 300w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2282-4-768x576.jpg 768w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2282-4-1536x1152.jpg 1536w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2282-4-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 819px) 100vw, 819px\" \/><\/a><\/figure>\n\n\n\n<p>The back wall adds a complete look to the house and also supports the structure overall.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><a href=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2274-3-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2274-3-1024x768.jpg\" alt=\"\" class=\"wp-image-5925\" width=\"828\" height=\"621\" srcset=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2274-3-1024x768.jpg 1024w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2274-3-300x225.jpg 300w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2274-3-768x576.jpg 768w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2274-3-1536x1152.jpg 1536w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2274-3-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/a><\/figure>\n\n\n\n<p>First, print out another house template, then cut it to shape.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><a href=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2284-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2284-1024x768.jpg\" alt=\"\" class=\"wp-image-5922\" width=\"818\" height=\"614\" srcset=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2284-1024x768.jpg 1024w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2284-300x225.jpg 300w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2284-768x576.jpg 768w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2284-1536x1152.jpg 1536w, https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/IMG_2284-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 818px) 100vw, 818px\" \/><\/a><\/figure>\n\n\n\n<p>Then glue the back wall into the house after installing the garage door.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">The Code<\/h5>\n\n\n\n<p>In the final chapter, we want to focus on the code that allows the house functions to integrate together. Furthermore, we will talk about elevating the project to the next level. When the Smart House is fully equipped with sensors and systems that provide comfort and convenience for the occupants, these systems need to work together harmonically by using the Smart House Controlling System (SHCS) to process the input sensors and making decisions using these inputs.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Let talk about what changed <\/h6>\n\n\n\n<p>I clean up the code since I know this would be the final chapter of this project. There might be changed in variable name but the mechanic of the code is the same. You can copy the complete code at the bottom of this section.<\/p>\n\n\n\n<p>Add the servo library and name the servo motor<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;Servo.h&gt;\nServo GarageServo;<\/code><\/pre>\n\n\n\n<p>Make sure to attach the servo to the correct pin.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void setup()\n{\n    \/\/ set up serial at 9600 baud   \n    Serial.begin(9600);\n    \n    pinMode(First_Floor_LED, OUTPUT);\n    pinMode(Second_Floor_LED, OUTPUT);\n    pinMode(Front_Door_LED, OUTPUT);\n    \n    pinMode(IN1,OUTPUT);\n    pinMode(IN2,OUTPUT); \n    pinMode(ENA,OUTPUT);\n\n  GarageServo.attach(11);\n  GarageDoor(2);   \n  WelcomeSong();\n}<\/code><\/pre>\n\n\n\n<p>Simple block code to control the Garage.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void GarageDoor(int GarageStage)\n{\n  \n  int pos; \n  if( GarageStage == 1)\n  {\n      GarageServo.write(180);              \n\n  }\n  if( GarageStage == 2)\n  {\n     GarageServo.write(60);              \n  }\n  \n}<\/code><\/pre>\n\n\n\n<p>Add variables for the time stamp. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ convert the 10bit analog value to celcius\ntemperature = float(analogValue) \/ 1023;\ntempunsigned long previousMillis = 0;        \/\/ will store last time LED was updated\n\n\/\/ constants won't change:\nconst long interval = 50000;           \n\nconst long Sound_interval = 50;\nconst long LightSensor_interval = 100;\nconst long Temperature_interval = 500;\n\nunsigned long previous_Sound_interval = 0;  \nunsigned long previous_LightSensor_interval = 0;  \nunsigned long previous_Temperature_interval = 0;  <\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">The heart of the code.<\/h6>\n\n\n\n<p>The loop is now fairly simple and free of delay. Based on the time integral of each sensor, the control systems will work independently at the same time. This will help the Smart House Controlling System (SCS) receive the sensor data at different rates since&nbsp;each sensor gets its data at a different rate. For instance, the sound sensor would need to trigger less often due to the nature of the piezo sensor. With the time stamp system, the (SCS) can do multiple things at the same time such as managing security, AC system, Lighting System, and motion control.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void loop()\n{\n    unsigned long currentMillis = millis();\n    \n    int flag = 0;\n\n    \n     if (flag==1){Serial.println(\" Smart House Statuse\");}\n\n     if (currentMillis - previousMillis &gt;= LightSensor_interval) {previous_LightSensor_interval=currentMillis;LightSytem(flag);}\n     if (currentMillis - previousMillis &gt;= Sound_interval) {previous_Sound_interval=currentMillis;Alarm_System(flag);}\n     if (currentMillis - previousMillis &gt;= Temperature_interval) {previous_Temperature_interval=currentMillis;AC_Control(flag);}\n\n     \n     if (currentMillis - previousMillis &gt;= interval) \n     {\n     previousMillis = currentMillis;\n     \n     if (Garage_Stage == LOW)\n     {\n      Garage_Stage = HIGH;\n      GarageDoor(1);\n     }\n     else\n     {\n      Garage_Stage = LOW;\n      GarageDoor(2);\n     }    \n   }\n\n}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Full Code<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Project: Smart House 06\/18\/2021\n\n\/\/ include our list of note pitches\n\n#include \"pitches.h\"\n#include &lt;Servo.h&gt;\n\nServo GarageServo;\n\nint Front_Door_LED = 2 ;\nint First_Floor_LED = 3;\nint Second_Floor_LED = 5;\n\nint IN1=8;\nint IN2=9;\nint ENA=10;\n\n\/\/ the photocell voltage divider pin\nint photocellPin = A0;\nint piezoPin = A1;\nint lm35Pin = A2;\n\n\/\/ the pin the speaker is attached to\nint speakerPin = 7;\n\n\nconst int sensorMin = 0;\n\/\/ sensor maximum, discovered through experiment\nconst int sensorMax = 800;\nconst int threshold = 8; \n\n\/\/ the notes in our melody and their duration in fractions of a second\n\/\/ e.g. quarter note = 4, eighth note = 8, etc.\nconst int melody1&#91;]&#91;2] = \n{\n    {NOTE_C4, 4},\n    {NOTE_G3, 8},\n    {NOTE_G3, 8},\n    {NOTE_A3, 4},\n    {NOTE_G3, 4},\n    {NOTE_BLANK, 4},\n    {NOTE_B3, 4},\n    {NOTE_C4, 4}\n};\n\n\n\n      int analogValue;\n      float temperature;\n\n      int Garage_Stage = LOW;\n   \nvoid setup()\n{\n    \/\/ set up serial at 9600 baud   \n    Serial.begin(9600);\n    \n    pinMode(First_Floor_LED, OUTPUT);\n    pinMode(Second_Floor_LED, OUTPUT);\n    pinMode(Front_Door_LED, OUTPUT);\n    \n    pinMode(IN1,OUTPUT);\n    pinMode(IN2,OUTPUT); \n    pinMode(ENA,OUTPUT);\n\n  GarageServo.attach(11);\n  GarageDoor(2);   \n  WelcomeSong();\n}\n\nunsigned long previousMillis = 0;        \/\/ will store last time LED was updated\n\n\/\/ constants won't change:\nconst long interval = 50000;           \n\nconst long Sound_interval = 50;\nconst long LightSensor_interval = 100;\nconst long Temperature_interval = 500;\n\nunsigned long previous_Sound_interval = 0;  \nunsigned long previous_LightSensor_interval = 0;  \nunsigned long previous_Temperature_interval = 0;  \n\n  \nvoid loop()\n{\n    unsigned long currentMillis = millis();\n    \n    int flag = 0;\n\n    \n     if (flag==1){Serial.println(\" Smart House Statuse\");}\n\n     if (currentMillis - previousMillis &gt;= LightSensor_interval) {previous_LightSensor_interval=currentMillis;LightSytem(flag);}\n     if (currentMillis - previousMillis &gt;= Sound_interval) {previous_Sound_interval=currentMillis;Alarm_System(flag);}\n     if (currentMillis - previousMillis &gt;= Temperature_interval) {previous_Temperature_interval=currentMillis;AC_Control(flag);}\n\n     \n     if (currentMillis - previousMillis &gt;= interval) \n     {\n     previousMillis = currentMillis;\n     \n     if (Garage_Stage == LOW)\n     {\n      Garage_Stage = HIGH;\n      GarageDoor(1);\n     }\n     else\n     {\n      Garage_Stage = LOW;\n      GarageDoor(2);\n     }    \n   }\n\n}\n\nvoid GarageDoor(int GarageStage)\n{\n  \n  int pos; \n  if( GarageStage == 1)\n  {\n      GarageServo.write(180);              \/\/ tell servo to go to position in variable 'pos'\n\n  }\n  if( GarageStage == 2)\n  {\n     GarageServo.write(60);              \/\/ tell servo to go to position in variable 'pos'\n  }\n  \n}\n\nvoid AC_Control(int flag)\n{\n  Read_Temp(flag);\n   if (temperature &gt;28)\n     {\n     AC_Motor(100);\n     }\n     if(temperature &lt;=28)\n     {\n      AC_Motor(0);\n     }\n}\nvoid AC_Motor(int speedR)\n{\n analogWrite(ENA, speedR);\/\/ motor speed  \n digitalWrite(IN2,LOW);\/\/ rotate forward\n digitalWrite(IN1,HIGH); \n}\nvoid Read_Temp(int flag)\n{\n      analogValue = analogRead(lm35Pin);\n\n    \/\/ convert the 10bit analog value to celcius\n    temperature = float(analogValue) \/ 1023;\n    temperature = temperature * 500;\n    \n    \/\/ print the temperature over serial\n    if(flag ==1)\n    {Serial.print(\"Temp: \");Serial.print(temperature);Serial.println(\"C\");}\n}\nvoid Alarm_System(int flag)\n{\n   int NoiseLevel;\n    \/\/ read the sensor and store it in the variable sensorReading:\n    NoiseLevel= analogRead(piezoPin);delay(100);\n    if(flag==1)\n    {Serial.print (\"NoiseLevel: \");Serial.println(NoiseLevel);}\n    \n    \/\/ if the sensor reading is greater than the threshold:\n    if (NoiseLevel &gt; threshold)\n    {\n        for(int i = 0; i&lt;10; i++) \n        { \n        alarm_sound();\n        LightControl(0,0);\n        delay(10);\n        }\n    }\n    \/\/ delay to avoid overloading the serial port buffer\n}\nvoid alarm_sound()\n{\n         \/\/ figure out the number of notes in our melody\n    int numberOfNotes = sizeof(melody1) \/ sizeof(melody1&#91;0]);\n    \/\/ iterate over the notes of the melody\n    for (int thisNote = 0; thisNote &lt; numberOfNotes; thisNote++)\n    {\n        \/\/ grab our note and note duration from our array\n        int thisNoteTone = melody1&#91;thisNote]&#91;0];\n        int thisNoteDuration = melody1&#91;thisNote]&#91;1];\n        int noteDurationMS = 100 \/ thisNoteDuration;\n        \/\/ play the note\n        tone(speakerPin, thisNoteTone, noteDurationMS);\n        delay(noteDurationMS * 1.30);\n    }\n}\n\nint WelcomeSong()\n{\n    int numberOfNotes = sizeof(melody1) \/ sizeof(melody1&#91;0]);\n    for (int thisNote = 0; thisNote &lt; numberOfNotes; thisNote++)\n    {\n        int thisNoteTone = melody1&#91;thisNote]&#91;0];\n        int thisNoteDuration = melody1&#91;thisNote]&#91;1];\n        int noteDurationMS = 1000 \/ thisNoteDuration;\n        \/\/ play the note\n        tone(speakerPin, thisNoteTone, noteDurationMS);\n        delay(noteDurationMS * 1.30);\n    }\n}\n\nvoid LightSytem(int flag)\n{\n int Brightness;\n\n    Brightness = analogRead(photocellPin);\n    if(flag==1)\n    {Serial.print(\"Brightness:  \");Serial.println(Brightness);}\n    \n    LightControl(Brightness, flag);\n    \n    delay(25);\n}\n\nvoid LightControl(int LightLevel, int flag)\n{\n  int Light = map(LightLevel,0,1020,250,0);\n  if(flag==1)\n  {Serial.print(\"Light level: \");Serial.println(Light);}\n  \n    analogWrite(First_Floor_LED, Light);\n    analogWrite(Second_Floor_LED,Light);\n    analogWrite(Front_Door_LED,Light);\n    \n}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Conclusion <\/h5>\n\n\n\n<p>The Smart House project has come to an end with LED light system, Security System, AC control system, and Motion control system all integrate with the Smart House <a href=\"\/programmable-logic-controllers\">Controlling System<\/a> (SHCS). In every project, it is important to ask what next, with the Smart House project this is just the beginning. The Smart House now is full of potential to do so much more. For instance, the SHCS can receive all the sensor data then compare them before reacting to the input. One of the cases would be the light level and the temperature inputs, where the SHCH can make a decision on how to run the AC system. Furthermore, the SHCH can go wireless and control smart devices via Bluetooth or WIFI. The video below will demonstrate how all the systems work together. <\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"The Smart House Project - Final Chapter\" width=\"800\" height=\"450\" src=\"https:\/\/www.youtube.com\/embed\/EJdOKqARGOo?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The Smart House Project is almost at the final stage, so let&#8217;s do a recap on everything we have done<\/p>\n","protected":false},"author":10687,"featured_media":7849,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_layout":"default_layout","footnotes":""},"categories":[1,124,8,21,287,135],"tags":[129,132,143],"class_list":["post-5903","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-all-posts","category-arduino","category-diy","category-education-kits","category-electronic-kits","category-tutorial-how-to","tag-arduino","tag-makers","tag-prototyping"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The Smart House Project \u2013 Part 4 | Simply Smarter Circuitry Blog<\/title>\n<meta name=\"description\" content=\"The Smart House Project is almost at the final stage, so let&#039;s do a recap on everything we have done so far.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Smart House Project \u2013 Part 4 | Simply Smarter Circuitry Blog\" \/>\n<meta property=\"og:description\" content=\"The Smart House Project is almost at the final stage, so let&#039;s do a recap on everything we have done so far.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/\" \/>\n<meta property=\"og:site_name\" content=\"Simply Smarter Circuitry Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/CircuitSpecialists\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-22T18:07:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-29T17:13:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Untitled-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1523\" \/>\n\t<meta property=\"og:image:height\" content=\"996\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Khang\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CircuitSpecial\" \/>\n<meta name=\"twitter:site\" content=\"@CircuitSpecial\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Khang\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/\"},\"author\":{\"name\":\"Khang\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/2004b049c7f4ad1ef1c677c13230001e\"},\"headline\":\"The Smart House Project \u2013 Part 4\",\"datePublished\":\"2021-06-22T18:07:42+00:00\",\"dateModified\":\"2022-07-29T17:13:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/\"},\"wordCount\":794,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Untitled-1.png\",\"keywords\":[\"Arduino\",\"Makers\",\"Prototyping\"],\"articleSection\":[\"All Posts\",\"Arduino\",\"DIY\",\"Education Kits\",\"Electronic Kits\",\"Tutorial \/ How-to\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/\",\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/\",\"name\":\"The Smart House Project \u2013 Part 4 | Simply Smarter Circuitry Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Untitled-1.png\",\"datePublished\":\"2021-06-22T18:07:42+00:00\",\"dateModified\":\"2022-07-29T17:13:11+00:00\",\"description\":\"The Smart House Project is almost at the final stage, so let's do a recap on everything we have done so far.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#primaryimage\",\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Untitled-1.png\",\"contentUrl\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Untitled-1.png\",\"width\":1523,\"height\":996},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.circuitspecialists.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Smart House Project \u2013 Part 4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#website\",\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/\",\"name\":\"Simply Smarter Circuitry Blog\",\"description\":\"How To&#039;s, Reviews, and Product News from Circuit Specialists HQ.\",\"publisher\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.circuitspecialists.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#organization\",\"name\":\"Circuit Specialists\",\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2016\/03\/csi.jpg\",\"contentUrl\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2016\/03\/csi.jpg\",\"width\":120,\"height\":120,\"caption\":\"Circuit Specialists\"},\"image\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/CircuitSpecialists\/\",\"https:\/\/x.com\/CircuitSpecial\",\"https:\/\/www.youtube.com\/channel\/UCG87WTqDKIqA704uqjumJgg\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/2004b049c7f4ad1ef1c677c13230001e\",\"name\":\"Khang\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ffe2b76fa2901ed9a217ed89e6528178?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ffe2b76fa2901ed9a217ed89e6528178?s=96&r=g\",\"caption\":\"Khang\"},\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/author\/khang\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Smart House Project \u2013 Part 4 | Simply Smarter Circuitry Blog","description":"The Smart House Project is almost at the final stage, so let's do a recap on everything we have done so far.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/","og_locale":"en_US","og_type":"article","og_title":"The Smart House Project \u2013 Part 4 | Simply Smarter Circuitry Blog","og_description":"The Smart House Project is almost at the final stage, so let's do a recap on everything we have done so far.","og_url":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/","og_site_name":"Simply Smarter Circuitry Blog","article_publisher":"https:\/\/www.facebook.com\/CircuitSpecialists\/","article_published_time":"2021-06-22T18:07:42+00:00","article_modified_time":"2022-07-29T17:13:11+00:00","og_image":[{"width":1523,"height":996,"url":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Untitled-1.png","type":"image\/png"}],"author":"Khang","twitter_card":"summary_large_image","twitter_creator":"@CircuitSpecial","twitter_site":"@CircuitSpecial","twitter_misc":{"Written by":"Khang","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#article","isPartOf":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/"},"author":{"name":"Khang","@id":"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/2004b049c7f4ad1ef1c677c13230001e"},"headline":"The Smart House Project \u2013 Part 4","datePublished":"2021-06-22T18:07:42+00:00","dateModified":"2022-07-29T17:13:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/"},"wordCount":794,"commentCount":0,"publisher":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#primaryimage"},"thumbnailUrl":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Untitled-1.png","keywords":["Arduino","Makers","Prototyping"],"articleSection":["All Posts","Arduino","DIY","Education Kits","Electronic Kits","Tutorial \/ How-to"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/","url":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/","name":"The Smart House Project \u2013 Part 4 | Simply Smarter Circuitry Blog","isPartOf":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#primaryimage"},"image":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#primaryimage"},"thumbnailUrl":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Untitled-1.png","datePublished":"2021-06-22T18:07:42+00:00","dateModified":"2022-07-29T17:13:11+00:00","description":"The Smart House Project is almost at the final stage, so let's do a recap on everything we have done so far.","breadcrumb":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#primaryimage","url":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Untitled-1.png","contentUrl":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2021\/06\/Untitled-1.png","width":1523,"height":996},{"@type":"BreadcrumbList","@id":"https:\/\/www.circuitspecialists.com\/blog\/the-smart-house-project-part-4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.circuitspecialists.com\/blog\/"},{"@type":"ListItem","position":2,"name":"The Smart House Project \u2013 Part 4"}]},{"@type":"WebSite","@id":"https:\/\/www.circuitspecialists.com\/blog\/#website","url":"https:\/\/www.circuitspecialists.com\/blog\/","name":"Simply Smarter Circuitry Blog","description":"How To&#039;s, Reviews, and Product News from Circuit Specialists HQ.","publisher":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.circuitspecialists.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.circuitspecialists.com\/blog\/#organization","name":"Circuit Specialists","url":"https:\/\/www.circuitspecialists.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2016\/03\/csi.jpg","contentUrl":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2016\/03\/csi.jpg","width":120,"height":120,"caption":"Circuit Specialists"},"image":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/CircuitSpecialists\/","https:\/\/x.com\/CircuitSpecial","https:\/\/www.youtube.com\/channel\/UCG87WTqDKIqA704uqjumJgg"]},{"@type":"Person","@id":"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/2004b049c7f4ad1ef1c677c13230001e","name":"Khang","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ffe2b76fa2901ed9a217ed89e6528178?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ffe2b76fa2901ed9a217ed89e6528178?s=96&r=g","caption":"Khang"},"url":"https:\/\/www.circuitspecialists.com\/blog\/author\/khang\/"}]}},"_links":{"self":[{"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/posts\/5903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/users\/10687"}],"replies":[{"embeddable":true,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/comments?post=5903"}],"version-history":[{"count":19,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/posts\/5903\/revisions"}],"predecessor-version":[{"id":7850,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/posts\/5903\/revisions\/7850"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/media\/7849"}],"wp:attachment":[{"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/media?parent=5903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/categories?post=5903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/tags?post=5903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}