{"id":97,"date":"2025-11-02T14:42:26","date_gmt":"2025-11-02T19:42:26","guid":{"rendered":"https:\/\/wp.stgeorges.bc.ca\/deans\/?p=97"},"modified":"2025-11-04T16:48:25","modified_gmt":"2025-11-04T21:48:25","slug":"robotics-project","status":"publish","type":"post","link":"https:\/\/wp.stgeorges.bc.ca\/deans\/2025\/11\/02\/robotics-project\/","title":{"rendered":"ROBOTICS PROJECT"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">INTRO<\/h2>\n\n\n\n<p>For this robotics assignment, I designed and built a motion-activated automatic door using Arduino Uno, PIR motion sensor, and servo motor. The goal of the project was to demonstrate core Arduino skills such as circuit building and coding, while creating a functional robotic device that reacts to human movement. I created and tested the circuit virtually using Tinkercad before attempting real life assembly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">OVERVIEW<\/h2>\n\n\n\n<p>The project simulates an automatic door that opens when a person approaches. When the PIR sensor detects motion, it sends a signal to the Arduino, which then activates the servo motor to open the door. After a three-second delay, the servo returns to its original position, closing the door.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>CODE<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;Servo.h&gt;\n\nServo doorServo;     \nint pirPin = 2;        \nint pirState = LOW;   \n\nvoid setup() {\n  doorServo.attach(9);   \n  pinMode(pirPin, INPUT); \n  doorServo.write(0);   \n}\n\nvoid loop() {\n  int motionDetected = digitalRead(pirPin);\n\n  if (motionDetected == HIGH &amp;&amp; pirState == LOW) {\n    doorServo.write(90); \n    pirState = HIGH;\n    delay(3000);         \n    doorServo.write(0); \n    pirState = LOW;\n  }\n\n  delay(200); \n}\n<\/code><\/pre>\n\n\n\n<p>CODE BREAKDOWN<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;Servo.h&gt;\n\nServo doorServo;       \nint pirPin = 2;        \nint pirState = LOW;    \n<\/code><\/pre>\n\n\n\n<p>This section includes the servo library, which allows the Arduino to control servo motors. It creates a servo object called <strong>doorServo<\/strong> for controlling the door. <strong>pirPin<\/strong> defines    which pin the PIR sensor is connected to, and <strong>pirState<\/strong> keeps track of whether motion has been detected, helping to prevent the door from repeatedly opening when motion is continuous.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void setup() {\n  doorServo.attach(9);   \n  pinMode(pirPin, INPUT);\n  doorServo.write(0);    \n}<\/code><\/pre>\n\n\n\n<p>In the <strong>setup()<\/strong> function, the servo is attached to pin 9, which will control the door. The PIR sensor pin is set as an input so the Arduino can read motion detection signals. Finally, <strong>doorServo.write(0) <\/strong>ensures the door starts in the closed position when the program begins.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void loop() {\n  int motionDetected = digitalRead(pirPin);\n\n  if (motionDetected == HIGH &amp;&amp; pirState == LOW) {\n    doorServo.write(90);  \n    pirState = HIGH;\n    delay(3000);          \n    doorServo.write(0);   \n    pirState = LOW;\n  }\n\n  delay(200); \n}<\/code><\/pre>\n\n\n\n<p>The <strong>loop()<\/strong> function constantly reads the PIR sensor with <strong>digitalRead(pirPin)<\/strong>. If motion is detected (<strong>motionDetected == HIGH<\/strong>) and the door is not already open (<strong>pirState == LOW<\/strong>), the servo rotates to 90\u00b0 to open the door. The program waits for 3 seconds before closing the door by returning the servo to 0\u00b0. The <strong>pirState<\/strong> variable prevents repeated triggering while motion continues, and the <strong>delay(200)<\/strong> at the end prevents jitter from rapid sensor signals.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">BILL OF MATERIALS (BOM)<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Component<\/th><th>Quantity<\/th><th>Function<\/th><\/tr><\/thead><tbody><tr><td>Arduino Uno<\/td><td>1<\/td><td>Microcontroller board<\/td><\/tr><tr><td>PIR Motion Sensor<\/td><td>1<\/td><td>Detects motion (input)<\/td><\/tr><tr><td>Servo Motor <\/td><td>1<\/td><td>Controls door movement (output)<\/td><\/tr><tr><td>Jumper Wires<\/td><td>6<\/td><td>Electrical connections<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">VIRTUAL PROTOTYPE<\/h2>\n\n\n\n<p>I used Tinkercad to build the first version of the circuit to ensure both the wiring and code worked properly before physical assembly.<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"901\" src=\"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/11\/Screenshot-2025-11-01-at-16.58.14-1024x901.png\" alt=\"\" class=\"wp-image-98\" srcset=\"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/11\/Screenshot-2025-11-01-at-16.58.14-1024x901.png 1024w, https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/11\/Screenshot-2025-11-01-at-16.58.14-300x264.png 300w, https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/11\/Screenshot-2025-11-01-at-16.58.14-768x676.png 768w, https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/11\/Screenshot-2025-11-01-at-16.58.14-1536x1352.png 1536w, https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/11\/Screenshot-2025-11-01-at-16.58.14.png 1582w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The circuit works as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The PIR sensor detects motion and outputs a digital HIGH signal on pin 2 when movement is detected.<\/li>\n\n\n\n<li>The servo motor receives control signals from pin 9 to rotate between the closed (0\u00b0) and open (90\u00b0) positions.<\/li>\n\n\n\n<li>The Arduino powers and controls both components.<\/li>\n<\/ul>\n\n\n\n<p>VIRTUAL <strong>DEMONSTRATION<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1440\" style=\"aspect-ratio: 1614 \/ 1440;\" width=\"1614\" controls src=\"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/11\/Screen-Recording-2025-11-02-at-16.mp4\"><\/video><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Physical Prototype<\/h2>\n\n\n\n<p>I went ahead and built the real-life version of the door with the Arduino, servo, and button. Everything was connected exactly like in the virtual Tinkercad version, but when I tried to upload the code, it just wouldn\u2019t work.<\/p>\n\n\n\n<p>The problem was with my Mac, the Arduino IDE couldn\u2019t detect any ports, so the board didn\u2019t respond. Because of that, I couldn\u2019t test the servo in real life. Even though it\u2019s built and wired correctly, I could only fully test it in Tinkercad.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">USE OF AI<\/h2>\n\n\n\n<p>I used AI mainly to help with the code and clear up a few things I wasn\u2019t sure about. It gave me quick explanations and helped me fix mistakes faster. Overall, it made the project easier to understand and finish.<br><\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-a89b3969 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-width wp-block-button__width-75 is-style-fill\"><a class=\"wp-block-button__link has-base-color has-contrast-background-color has-text-color has-background has-link-color has-large-font-size has-custom-font-size wp-element-button\" href=\"https:\/\/docs.google.com\/document\/d\/1bfZCQ32JEvWC3TY4cB1b_FG6Y3YMJYdvR5iSUlUi9sY\/edit?tab=t.0\" style=\"border-width:20px;border-radius:80px\">AI TRANSCRIPT<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">SUMMARY<\/h2>\n\n\n\n<p>This project was especially useful because it taught me things I hadn\u2019t learned in the robotics courses I took before. I learned how to read sensor input with <strong>digitalRead()<\/strong>, control a servo with <strong>servo.write()<\/strong>, and manage timing using <strong>delay()<\/strong>. Even though I couldn\u2019t upload the code to a real Arduino, running the project in Tinkercad helped me understand how everything works together. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>INTRO For this robotics assignment, I designed and built a motion-activated automatic door using Arduino Uno, PIR motion sensor, and servo motor. The goal of the project was to demonstrate core Arduino skills such as circuit building and coding, while creating a functional robotic device that reacts to human movement. I created and tested the [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-97","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/posts\/97","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/comments?post=97"}],"version-history":[{"count":12,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":113,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/posts\/97\/revisions\/113"}],"wp:attachment":[{"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/media?parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/categories?post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/tags?post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}