{"id":1591,"date":"2018-05-24T13:24:04","date_gmt":"2018-05-24T20:24:04","guid":{"rendered":"http:\/\/www.donluc.com\/?p=1591"},"modified":"2018-05-24T13:24:04","modified_gmt":"2018-05-24T20:24:04","slug":"project-7-rgb-lcd-shield-pir-motion-sensor-mk03","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=1591","title":{"rendered":"Project #7: RGB LCD Shield \u2013 PIR Motion Sensor &#8211; Mk03"},"content":{"rendered":"<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07b.png\" alt=\"\" width=\"720\" height=\"653\" class=\"alignnone size-full wp-image-1592\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07b-300x272.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07c.png\" alt=\"\" width=\"720\" height=\"654\" class=\"alignnone size-full wp-image-1593\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07c-300x273.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07d.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07d.png\" alt=\"\" width=\"720\" height=\"540\" class=\"alignnone size-full wp-image-1594\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07d.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07d-300x225.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07e.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07e.png\" alt=\"\" width=\"720\" height=\"720\" class=\"alignnone size-full wp-image-1595\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07e.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07e-150x150.png 150w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07e-300x300.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-1591-1\" width=\"720\" height=\"406\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/05\/DonLuc1805Mk07.mp4<\/a><\/video><\/div>\n<p><strong>PIR Motion Sensor<\/strong><\/p>\n<p>This is a simple to use motion sensor. Power it up and wait 1-2 seconds for the sensor to get a snapshot of the still room. If anything moves after that period, the \u2018alarm\u2019 pin will go low.<\/p>\n<p>This unit works great from 5 to 12V (datasheet shows 12V). You can also install a jumper wire past the 5V regulator on board to make this unit work at 3.3V. Sensor uses 1.6mA@3.3V.<\/p>\n<p>The alarm pin is an open collector meaning you will need a pull up resistor on the alarm pin. The open drain setup allows multiple motion sensors to be connected on a single input pin. If any of the motion sensors go off, the input pin will be pulled low.<\/p>\n<p>We\u2019ve finally updated the connector! Gone is the old \u201codd\u201d connector, now you will find a common 3-pin JST! This makes the PIR Sensor much more accessible for whatever your project may need. Red = Power, White = Ground, and Black = Alarm.<\/p>\n<p><strong>Buzzer<\/strong><\/p>\n<p>This is a small 12mm round speaker that operates around the audible 2kHz range. You can use these speakers to create simple music or user interfaces.<\/p>\n<p>This is not a true piezoelectric speaker but behaves similarly. Instead of a piezoelectric crystal that vibrates with an electric current, this tiny speaker uses an electromagnet to drive a thin metal sheet. That means you need to use some form of alternating current to get sound. The good news is that this speaker is tuned to respond best with a square wave (e.g. from a microcontroller).<\/p>\n<p><strong>LED<\/strong><\/p>\n<p>LED Yellow<br \/>\nLED Green<\/p>\n<p><strong>DonLuc1805Mk07<\/strong><\/p>\n<p>1 x RGB LCD Shield 16\u00d72 Character Display<br \/>\n1 x Arduino UNO &#8211; R3<br \/>\n1 x ProtoScrewShield<br \/>\n1 x PIR Motion Sensor<br \/>\n1 x Buzzer<br \/>\n1 x LED Yellow<br \/>\n1 x LED Green<br \/>\n2 x Jumper Wires 2&#8243; M\/F<br \/>\n4 x Jumper Wires 3&#8243; M\/M<br \/>\n5 x Jumper Wires 6&#8243; M\/M<br \/>\n1 x Half-Size Breadboard<\/p>\n<p><strong>Arduino UNO<\/strong><\/p>\n<p>JST &#8211; Digital 6<br \/>\nBUZ &#8211; Digital 2<br \/>\nLEY &#8211; Digital 1<br \/>\nLEG &#8211; Digital 0<br \/>\nVIN &#8211; +5V<br \/>\nGND &#8211; GND<\/p>\n<p><strong>DonLuc1805Mk07a.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"DonLuc1805Mk07a.ino\">\r\n\/\/ ***** Don Luc *****\r\n\/\/ Software Version Information\r\n\/\/ Project #7: RGB LCD Shield \u2013 PIR Motion Sensor - Mk03\r\n\/\/ 5-3.01\r\n\/\/ DonLuc1804Mk07 5-3.01\r\n\/\/ RGB LCD Shield\r\n\/\/ PIR Motion Sensor (JST}\r\n\r\n\/\/ include the library code:\r\n#include &lt;Adafruit_MCP23017.h&gt;\r\n#include &lt;Adafruit_RGBLCDShield.h&gt;\r\n\r\nAdafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();\r\n#define GREEN 0x2\r\n\r\n\/\/ PIR Motion Sensor (JST}\r\nconst int buz = 6;          \/\/ Buzzer\r\nconst int MOTION_PIN = 2;   \/\/ Pin connected to motion detector\r\nconst int LED_Yellow = 1;   \/\/ LED Yellow\r\nconst int LED_Green = 0;    \/\/ LED Green\r\n\r\nvoid loop() {\r\n\r\n  \/\/ PIR Motion Sensor (JST}\r\n  isJST();\r\n\r\n  delay(1000);\r\n  \r\n  \/\/ Clear\r\n  RGBLCDShield.clear();\r\n  \r\n}\r\n<\/pre>\n<p><strong>getJST.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"getJST.ino\">\r\nvoid isJST(){\r\n  \r\n  int proximity = digitalRead(MOTION_PIN);   \/\/ PIR Motion Sensor\r\n  \r\n  if (proximity == LOW) \/\/ If the sensor&#039;s output goes low, motion is detected\r\n  {\r\n\r\n    \/\/ Motion Detected\r\n    digitalWrite(buz, HIGH);         \/\/ Buzzer High\r\n    digitalWrite(LED_Yellow, HIGH);  \/\/ LED Yellow High\r\n    digitalWrite(LED_Green, LOW);    \/\/ LED Green Low\r\n    \r\n    \/\/ Display\r\n    \/\/ Set the cursor to column 0, line 0  \r\n    RGBLCDShield.setCursor(0,0);\r\n    RGBLCDShield.print(&quot;Motion Detected!&quot;);   \/\/ Motion Detected!\r\n    \/\/ Set the cursor to column 0, line 1\r\n    RGBLCDShield.setCursor(0, 1);\r\n    RGBLCDShield.print(&quot;Buzzer On - Yel&quot;);     \/\/ Buzzer On\r\n   \r\n  }\r\n  else\r\n  {\r\n\r\n    \/\/ Motion Off\r\n    digitalWrite(buz, LOW);         \/\/ Buzzer Low\r\n    digitalWrite(LED_Yellow, LOW);  \/\/ LED Yellow Low\r\n    digitalWrite(LED_Green, HIGH);  \/\/ LED Green High\r\n    \r\n    \/\/ Display\r\n    \/\/ Set the cursor to column 0, line 0  \r\n    RGBLCDShield.setCursor(0,0);\r\n    RGBLCDShield.print(&quot;Motion Off!&quot;);        \/\/ Motion Off!\r\n    \/\/ Set the cursor to column 0, line 1\r\n    RGBLCDShield.setCursor(0, 1);\r\n    RGBLCDShield.print(&quot;Buzzer Off - Gr&quot;);    \/\/ &quot;Buzzer Off\r\n          \r\n  }\r\n  \r\n}\r\n<\/pre>\n<p><strong>setup.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"setup.ino\">\r\nvoid setup() {\r\n\r\n  \/\/ set up the LCD&#039;s number of columns and rows: \r\n  RGBLCDShield.begin(16, 2);\r\n  RGBLCDShield.setBacklight(GREEN);\r\n  \r\n  \/\/ Display\r\n  \/\/ Set the cursor to column 0, line 0  \r\n  RGBLCDShield.setCursor(0,0);  \r\n  RGBLCDShield.print(&quot;Don Luc&quot;);         \/\/ Don luc\r\n  \/\/ Set the cursor to column 0, line 1\r\n  RGBLCDShield.setCursor(0, 1);\r\n  RGBLCDShield.print(&quot;Motion Sensor&quot;);   \/\/ Motion Sensor\r\n\r\n  delay(5000);\r\n\r\n  \/\/ Clear\r\n  RGBLCDShield.clear();\r\n  \r\n  \/\/ PIR Motion Sensor (JST}\r\n  pinMode(buz, OUTPUT);                \/\/ Buzzer\r\n  pinMode(MOTION_PIN, INPUT_PULLUP);   \/\/ PIR Motion Sensor\r\n  pinMode(LED_Yellow, OUTPUT);         \/\/ LED Yellow\r\n  pinMode(LED_Green, OUTPUT);          \/\/ LED Green  \r\n      \r\n}\r\n<\/pre>\n<p><strong>Don Luc<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PIR Motion Sensor This is a simple to use motion sensor. Power it up and wait 1-2 seconds for the sensor to get a snapshot of the still room. If anything moves after that period, the \u2018alarm\u2019 pin will go low. This unit works great from 5 to 12V (datasheet shows 12V). You can also &#8230; <a title=\"Project #7: RGB LCD Shield \u2013 PIR Motion Sensor &#8211; Mk03\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=1591\" aria-label=\"Read more about Project #7: RGB LCD Shield \u2013 PIR Motion Sensor &#8211; Mk03\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71,47,50,38,59,5,58,10],"tags":[],"class_list":["post-1591","post","type-post","status-publish","format-standard","hentry","category-rgb-lcd-shield","category-adafruit","category-arduino","category-digitalelectronics","category-fritzing","category-microcontrollers","category-arduino-programming","category-projects"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1591"}],"version-history":[{"count":3,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1591\/revisions"}],"predecessor-version":[{"id":1599,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1591\/revisions\/1599"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}