{"id":539,"date":"2009-07-29T22:17:05","date_gmt":"2009-07-30T04:17:05","guid":{"rendered":"http:\/\/www.seeedstudio.com\/blog\/?p=539"},"modified":"2009-07-29T22:17:05","modified_gmt":"2009-07-30T04:17:05","slug":"electronic-brick-sensor","status":"publish","type":"post","link":"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/","title":{"rendered":"Electronic Brick : Sensor"},"content":{"rendered":"<p><a href=\"\/wp-content\/uploads\/2009\/07\/p1210737.jpg\"><\/a>\u00a0There are Analog sensor and Digital sensor.<br \/>\nSome Analog sensor as a switch, under some environment it output a \u2018on\u2019 signal and the other environment it output a \u2018off\u2019 signal.<br \/>\nWe take a Mercury tilt switch as an example. When the Mercury tilt switch brick up tilt, it will be on and sent out a high level signal, else it will be off and sent out a low level signal.<br \/>\nHook up the Mercury tilt switch brick to D9 connector of chassis, and hoop up the LED brick to D8 connector. Then By tilting to different end, it acts On\/Off like a switch.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/p1210737.jpg\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-540\" title=\"p1210737\" src=\"\/wp-content\/uploads\/2009\/07\/p1210737.jpg\" alt=\"\" width=\"500\" height=\"375\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2009\/07\/p1210737.jpg 1000w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2009\/07\/p1210737-300x225.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<pre>int Mercury_tilt = 9;\u00a0 \/\/define the 9th digital pin for Mercury tilt switch brick\r\nint Buzzer = 8;\u00a0\u00a0\u00a0\u00a0 \/\/define the 8th digital pin for LED brick<\/pre>\n<pre>void setup()\r\n{\r\n\u00a0 pinMode(Buzzer,OUTPUT); \/\/set the LED pin for digital output\r\n\u00a0 pinMode(Mercury_tilt,INPUT);\u00a0 \/\/set the tilt sensor pin for digital input\r\n}<\/pre>\n<pre>void loop()\r\n{\r\n\u00a0 if (digitalRead(Mercury_tilt)) \/\/ if up tilt\r\n\u00a0 digitalWrite(Buzzer,HIGH);\u00a0 \/\/ ring the Buzzer\r\n\u00a0 else\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ if not press\r\n\u00a0 digitalWrite(Buzzer,LOW);\u00a0\u00a0 \/\/ turn off the Buzzer\r\n}<\/pre>\n<p>Program the code into Arduino, and when the brick up tilt, the buzzer will ring to alarm.<\/p>\n<p>Some Digital sensor didn\u2019t like a switch just to put out high or low level signal in different situation.\u00a0 They put out an impulse signal when some situation.<br \/>\nAs a PIR sensor, when people move throw it, it will sent a high level impulse out. The impulse duration can be change by the resistance on the brick. The longer impulse holds up the easier to check by Arduino.<br \/>\nHook up the PIR sensor brick to D9 connector of Chassis, and hook up the LED brick to D8.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/p1210734.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-541\" title=\"p1210734\" src=\"\/wp-content\/uploads\/2009\/07\/p1210734.jpg\" alt=\"\" width=\"500\" height=\"375\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2009\/07\/p1210734.jpg 1000w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2009\/07\/p1210734-300x225.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<pre>int PIR = 9;\u00a0 \/\/define the 9th digital pin for PIR sensor brick\r\nint LED = 8;\u00a0\u00a0\u00a0\u00a0 \/\/define the 8th digital pin for LED brick\r\nint time=0; \/\/ initial the time<\/pre>\n<pre>void setup()\r\n{\r\n\u00a0 pinMode(LED,OUTPUT); \/\/set the LED pin for digital output\r\n\u00a0 pinMode(PIR,INPUT);\u00a0 \/\/set the tilt sensor pin for digital input\r\n}<\/pre>\n<pre>void loop()\r\n{\r\n\u00a0 if (digitalRead(PIR)) \/\/ if check people move throw\r\n\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0 time = 10000 ; \/\/ set a light time\r\n\u00a0 }\r\n\u00a0 if (time&gt;0) \/\/ check if need to light the LED\r\n\u00a0 {\r\n\u00a0\u00a0\u00a0 digitalWrite(LED,HIGH);\u00a0 \/\/ light the LED\r\n\u00a0\u00a0\u00a0 time--;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ decrease light time\u00a0\u00a0\u00a0\r\n\u00a0 }\r\n\u00a0 else\r\n\u00a0 {\r\n\u00a0\u00a0\u00a0 digitalWrite(LED,LOW);\u00a0 \/\/ turn off the LED\r\n\u00a0 }\r\n}<\/pre>\n<p>Program the code into Arduino, and when somebody passes by PIR sensor, the LED will light for a moment.<br \/>\nMore information about the PIR sensor is here:<br \/>\n<a href=\"http:\/\/www.seeedstudio.com\/depot\/pir-motion-sensor-module-p-74.html\">http:\/\/www.seeedstudio.com\/depot\/pir-motion-sensor-module-p-74.html<\/a><\/p>\n<p>The Analog sensor is different from Digital sensor, it output the different level analog signals when in different state. The level of analog signal reflect the reality signal that sensor cached, like light strength, gas density, temperature and so on.<\/p>\n<p>Now we take a Gas sensor for example. First, adjust the Resistor of the Brick to correct the sensor output analog level. When power up the gas sensor will heat and finally be warm, and then we can adjust the resistor to about 5K correct the output analog signal to about 1V.<\/p>\n<p>Hook up the Gas sensor brick to A1 connector of the chassis, and the buzzer to the D8 connector.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/p12107581.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-542\" title=\"p12107581\" src=\"\/wp-content\/uploads\/2009\/07\/p12107581.jpg\" alt=\"\" width=\"500\" height=\"375\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2009\/07\/p12107581.jpg 1000w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2009\/07\/p12107581-300x225.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<pre>int Gassensor = 1;\u00a0 \/\/define the 1th digital pin for gss sensor brick\r\nint Buzzer = 8;\u00a0\u00a0\u00a0\u00a0 \/\/define the 8th digital pin for buzzer brick<\/pre>\n<pre>void setup()\r\n{\r\n\u00a0 pinMode(Buzzer,OUTPUT); \/\/set the LED pin for digital output\r\n}<\/pre>\n<pre>void loop()\r\n{\r\n\u00a0 int val=0;\r\n\u00a0 val=analogRead(Gassensor); \/\/Read the gas sensor for gas density\r\n\u00a0 if (val&gt;0x300) \/\/ if gas dense\r\n\u00a0 {\r\n\u00a0\u00a0\u00a0 digitalWrite(Buzzer,HIGH); \/\/\u00a0 ring the Buzzer for alarm\r\n\u00a0 }\u00a0\r\n\u00a0 else\r\n\u00a0 {\r\n\u00a0\u00a0\u00a0 digitalWrite(Buzzer,LOW);\u00a0 \/\/ turn off the buzzer\r\n\u00a0 }\r\n}<\/pre>\n<p>More information about Gas sensor is here:<br \/>\nProgram the code into Arduino, and put the gas sensor brick in somewhere need to check gas density. If the gas density exceeds the value that we setup, the buzzer will ring for alarm.<\/p>\n<p>The light sensor is similar to gas sensor, it also output the analog signal by the reality signal: the luminous intensity. We can use the light sensor to control the light source turn on when is lightless and turn off if bright.<\/p>\n<p>Hook up the light sensor brick to A1 connector of chassis, and hook up the LED brick to D8 connector as a light source.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/p1210765.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-543\" title=\"p1210765\" src=\"\/wp-content\/uploads\/2009\/07\/p1210765.jpg\" alt=\"\" width=\"500\" height=\"375\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2009\/07\/p1210765.jpg 500w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2009\/07\/p1210765-300x225.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>\u00a0<\/p>\n<pre>int LightSensor = 1;\u00a0 \/\/define the 1th digital pin for light sensor brick\r\nint LED = 8;\u00a0\u00a0\u00a0\u00a0 \/\/define the 8th digital pin for LED brick<\/pre>\n<pre>void setup()\r\n{\r\n\u00a0 pinMode(LED,OUTPUT); \/\/set the LED pin for digital output\r\n}<\/pre>\n<pre>void loop()\r\n{\r\n\u00a0 int val=0;\r\n\u00a0 val=analogRead(LightSensor); \r\n  \/\/Read analog level which match the luminous intensity\r\n\u00a0 if (val&lt;0x200)\r\n\u00a0 {\r\n\u00a0\u00a0\u00a0 digitalWrite(LED,HIGH); \/\/\u00a0 turn on the light\r\n\u00a0 }\u00a0\r\n\u00a0 else\r\n\u00a0 {\r\n\u00a0\u00a0\u00a0 digitalWrite(LED,LOW);\u00a0 \/\/ turn off the light\r\n\u00a0 }\r\n}<\/pre>\n<p>Program the code into the Arduino, and when the light sensor around is dark the LED will light, but the light sensor around is light enough the LED will off.<\/p>\n<p>You can find more sensor brick here:<br \/>\n<a href=\"http:\/\/www.seeedstudio.com\/depot\/electronic-bricks-c-44.html\">http:\/\/www.seeedstudio.com\/depot\/electronic-bricks-c-44.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0There are Analog sensor and Digital sensor. Some Analog sensor as a switch, under some<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"iawp_total_views":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-539","post","type-post","status-publish","format-standard","hentry","category-news"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Electronic Brick : Sensor - Latest News from Seeed Studio<\/title>\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.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Electronic Brick : Sensor - Latest News from Seeed Studio\" \/>\n<meta property=\"og:description\" content=\"\u00a0There are Analog sensor and Digital sensor. Some Analog sensor as a switch, under some\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/\" \/>\n<meta property=\"og:site_name\" content=\"Latest News from Seeed Studio\" \/>\n<meta property=\"article:published_time\" content=\"2009-07-30T04:17:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.seeedstudio.com\/wp-content\/uploads\/2009\/07\/p1210737.jpg\" \/>\n<meta name=\"author\" content=\"\u884c\u653f\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u884c\u653f\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/\",\"url\":\"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/\",\"name\":\"Electronic Brick : Sensor - Latest News from Seeed Studio\",\"isPartOf\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#website\"},\"datePublished\":\"2009-07-30T04:17:05+00:00\",\"dateModified\":\"2009-07-30T04:17:05+00:00\",\"author\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/4a6f0df70e5aa1b470083e77a0919ba5\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.seeedstudio.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Electronic Brick : Sensor\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#website\",\"url\":\"https:\/\/www.seeedstudio.com\/blog\/\",\"name\":\"Latest News from Seeed Studio\",\"description\":\"Emerging IoT, AI and Autonomous Applications on the Edge\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.seeedstudio.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/4a6f0df70e5aa1b470083e77a0919ba5\",\"name\":\"\u884c\u653f\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4c87945076c1c9aea5570fea7739e112?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4c87945076c1c9aea5570fea7739e112?s=96&r=g\",\"caption\":\"\u884c\u653f\"},\"url\":\"https:\/\/www.seeedstudio.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Electronic Brick : Sensor - Latest News from Seeed Studio","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.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/","og_locale":"en_US","og_type":"article","og_title":"Electronic Brick : Sensor - Latest News from Seeed Studio","og_description":"\u00a0There are Analog sensor and Digital sensor. Some Analog sensor as a switch, under some","og_url":"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/","og_site_name":"Latest News from Seeed Studio","article_published_time":"2009-07-30T04:17:05+00:00","og_image":[{"url":"https:\/\/www.seeedstudio.com\/wp-content\/uploads\/2009\/07\/p1210737.jpg","type":"","width":"","height":""}],"author":"\u884c\u653f","twitter_card":"summary_large_image","twitter_misc":{"Written by":"\u884c\u653f","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/","url":"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/","name":"Electronic Brick : Sensor - Latest News from Seeed Studio","isPartOf":{"@id":"https:\/\/www.seeedstudio.com\/blog\/#website"},"datePublished":"2009-07-30T04:17:05+00:00","dateModified":"2009-07-30T04:17:05+00:00","author":{"@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/4a6f0df70e5aa1b470083e77a0919ba5"},"breadcrumb":{"@id":"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.seeedstudio.com\/blog\/2009\/07\/29\/electronic-brick-sensor\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.seeedstudio.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Electronic Brick : Sensor"}]},{"@type":"WebSite","@id":"https:\/\/www.seeedstudio.com\/blog\/#website","url":"https:\/\/www.seeedstudio.com\/blog\/","name":"Latest News from Seeed Studio","description":"Emerging IoT, AI and Autonomous Applications on the Edge","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.seeedstudio.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/4a6f0df70e5aa1b470083e77a0919ba5","name":"\u884c\u653f","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4c87945076c1c9aea5570fea7739e112?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4c87945076c1c9aea5570fea7739e112?s=96&r=g","caption":"\u884c\u653f"},"url":"https:\/\/www.seeedstudio.com\/blog\/author\/admin\/"}]}},"modified_by":null,"views":7944,"featured_image_urls":{"full":"","thumbnail":"","medium":"","medium_large":"","large":"","1536x1536":"","2048x2048":"","visody_icon":"","magazine-7-slider-full":"","magazine-7-slider-center":"","magazine-7-featured":"","magazine-7-medium":"","magazine-7-medium-square":""},"author_info":{"display_name":"\u884c\u653f","author_link":"https:\/\/www.seeedstudio.com\/blog\/author\/admin\/"},"category_info":"<a href=\"https:\/\/www.seeedstudio.com\/blog\/category\/news\/\" rel=\"category tag\">News<\/a>","tag_info":"News","comment_count":"0","_links":{"self":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/comments?post=539"}],"version-history":[{"count":3,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/539\/revisions"}],"predecessor-version":[{"id":546,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/539\/revisions\/546"}],"wp:attachment":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/media?parent=539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/categories?post=539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/tags?post=539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}