{"id":20038,"date":"2020-11-28T17:48:15","date_gmt":"2020-11-28T14:18:15","guid":{"rendered":"https:\/\/thecaferobot.com\/learn\/?p=20038"},"modified":"2021-06-20T16:15:57","modified_gmt":"2021-06-20T11:45:57","slug":"interfacing-tilt-switch-sensor-with-arduino","status":"publish","type":"post","link":"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/","title":{"rendered":"\u0622\u0645\u0648\u0632\u0634 \u0631\u0627\u0647 \u0627\u0646\u062f\u0627\u0632\u06cc \u0633\u0646\u0633\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686  \u0632\u0627\u0648\u06cc\u0647 \u0648 \u06a9\u062c\u06cc \u0628\u0627 \u0622\u0631\u062f\u0648\u06cc\u0646\u0648"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"20038\" class=\"elementor elementor-20038\">\n\t\t\t\t\t\t<div class=\"elementor-inner\">\n\t\t\t\t<div class=\"elementor-section-wrap\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-f458f08 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"f458f08\" data-element_type=\"section\">\r\n\t\t\t\r\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\r\n\t\t\t\t\t\t\t\t<div class=\"elementor-row\">\r\n\t\t\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-c925dc6\" data-id=\"c925dc6\" data-element_type=\"column\">\r\n\r\n\t\t\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\r\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\r\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-100681ff elementor-widget elementor-widget-heading\" data-id=\"100681ff\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">\u0648\u06cc\u0698\u06af\u06cc \u0647\u0627\u06cc \u0633\u0646\u0633\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u06a9\u062c\u06cc \u0648 \u0632\u0627\u0648\u06cc\u0647<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1798bf60 elementor-widget elementor-widget-text-editor\" data-id=\"1798bf60\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\">\n\t\t\t\t\u0639\u0645\u0644\u06a9\u0631\u062f \u0627\u06cc\u0646 \u0633\u0646\u0633\u0648\u0631 \u0634\u0628\u06cc\u0647 \u06cc\u06a9 \u0633\u0648\u0626\u06cc\u0686 \u0645\u06cc \u0628\u0627\u0634\u062f. \u062f\u0627\u062e\u0644 \u0645\u062d\u0641\u0638\u0647 \u06cc \u0627\u0633\u062a\u0648\u0627\u0646\u0647 \u0627\u06cc \u0633\u0646\u0633\u0648\u0631\u060c 2 \u0633\u0627\u0686\u0645\u0647 \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f. \u0628\u0627 \u062a\u0648\u062c\u0647 \u0628\u0647 \u0646\u062d\u0648\u0647 \u06cc \u0642\u0631\u0627\u0631 \u06af\u06cc\u0631\u06cc \u0627\u06cc\u0646 \u062f\u0648 \u0633\u0627\u0686\u0645\u0647\u060c \u0633\u0648\u0626\u06cc\u0686 \u0642\u0637\u0639 \u0648 \u0648\u0635\u0644 \u0645\u06cc \u0634\u0648\u062f.\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5ba22dad elementor-widget elementor-widget-image\" data-id=\"5ba22dad\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-image\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/Tilt-Switch-Module.jpg\" data-elementor-open-lightbox=\"yes\" data-elementor-lightbox-title=\"Tilt-Switch-Module.jpg\" e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MjAwNDEsInVybCI6Imh0dHBzOlwvXC90aGVjYWZlcm9ib3QuY29tXC9sZWFyblwvd3AtY29udGVudFwvdXBsb2Fkc1wvMjAyMFwvMTFcL1RpbHQtU3dpdGNoLU1vZHVsZS5qcGcifQ%3D%3D\">\n\t\t\t\t\t\t\t<img width=\"600\" height=\"600\" src=\"https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/Tilt-Switch-Module.jpg\" class=\"attachment-large size-large\" alt=\"\u0645\u0627\u0698\u0648\u0644 \u0633\u0648\u0626\u06cc\u0686 \u0632\u0627\u0648\u06cc\u0647 \u0648 \u06a9\u062c\u06cc\" loading=\"lazy\" \/>\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bf731 elementor-widget elementor-widget-heading\" data-id=\"bf731\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">\u0645\u0639\u0631\u0641\u06cc \u067e\u0627\u06cc\u0647 \u0647\u0627 (Pinout) \u0633\u0646\u0633\u0648\u0631 \u06a9\u062c\u06cc<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2ac6a51c elementor-widget elementor-widget-text-editor\" data-id=\"2ac6a51c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\">\n\t\t\t\t<p>\u0645\u0627\u0698\u0648\u0644 \u0633\u0646\u0633\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u06a9\u062c\u06cc \u0648 \u0632\u0627\u0648\u06cc\u0647 \u062f\u0627\u0631\u0627\u06cc 3 \u067e\u0627\u06cc\u0647 \u0628\u0647 \u0634\u0631\u062d \u0632\u06cc\u0631 \u0627\u0633\u062a:<\/p><ul><li><strong>VCC<\/strong><strong>:<\/strong> \u062a\u063a\u0630\u06cc\u0647 \u0645\u0627\u0698\u0648\u0644 \u2013 3.3 \u062a\u0627 5 \u0648\u0644\u062a<\/li><li><strong>GND<\/strong><strong>:<\/strong> \u0632\u0645\u06cc\u0646<\/li><li><strong>OUT<\/strong><strong>:<\/strong> \u062e\u0631\u0648\u062c\u06cc \u062f\u06cc\u062c\u06cc\u062a\u0627\u0644<\/li><\/ul><p>\u067e\u06cc\u0646 \u0627\u0648\u062a (Pinout) \u0627\u06cc\u0646 \u0645\u0627\u0698\u0648\u0644 \u0631\u0627 \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u062f\u0631 \u062a\u0635\u0648\u06cc\u0631 \u0632\u06cc\u0631 \u0645\u0634\u0627\u0647\u062f\u0647 \u06a9\u0646\u06cc\u062f.<\/p>\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6c9a2e10 elementor-widget elementor-widget-image\" data-id=\"6c9a2e10\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-image\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/Tilt-Switch-Pinout.jpg\" data-elementor-open-lightbox=\"yes\" data-elementor-lightbox-title=\"Tilt-Switch-Pinout.jpg\" e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MjAwNDIsInVybCI6Imh0dHBzOlwvXC90aGVjYWZlcm9ib3QuY29tXC9sZWFyblwvd3AtY29udGVudFwvdXBsb2Fkc1wvMjAyMFwvMTFcL1RpbHQtU3dpdGNoLVBpbm91dC5qcGcifQ%3D%3D\">\n\t\t\t\t\t\t\t<img width=\"800\" height=\"600\" src=\"https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/Tilt-Switch-Pinout.jpg\" class=\"attachment-large size-large\" alt=\"\u067e\u06cc\u0646 \u0627\u0648\u062a Pinout \u0633\u0646\u0633\u0648\u0631 \u06a9\u062c\u06cc\" loading=\"lazy\" \/>\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4d8ad6f5 elementor-widget elementor-widget-heading\" data-id=\"4d8ad6f5\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">\u0644\u0648\u0627\u0632\u0645\u06cc \u06a9\u0647 \u0628\u0647 \u0622\u0646 \u0627\u062d\u062a\u06cc\u0627\u062c \u062f\u0627\u0631\u06cc\u062f<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-64952b26 elementor-widget elementor-widget-image\" data-id=\"64952b26\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-image\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/Tilt-Switch-Required-Materials.jpg\" data-elementor-open-lightbox=\"yes\" data-elementor-lightbox-title=\"Tilt-Switch-Required-Materials.jpg\" e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MjAwNDMsInVybCI6Imh0dHBzOlwvXC90aGVjYWZlcm9ib3QuY29tXC9sZWFyblwvd3AtY29udGVudFwvdXBsb2Fkc1wvMjAyMFwvMTFcL1RpbHQtU3dpdGNoLVJlcXVpcmVkLU1hdGVyaWFscy5qcGcifQ%3D%3D\">\n\t\t\t\t\t\t\t<img width=\"600\" height=\"500\" src=\"https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/Tilt-Switch-Required-Materials.jpg\" class=\"attachment-large size-large\" alt=\"\" loading=\"lazy\" \/>\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1cf18def elementor-widget elementor-widget-heading\" data-id=\"1cf18def\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">\u0642\u0637\u0639\u0627\u062a \u0645\u0648\u0631\u062f \u0646\u06cc\u0627\u0632 <\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-54829b03 elementor-widget elementor-widget-html\" data-id=\"54829b03\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<div class=\"table-2\">\r\n<table width=\"100%\" class=\"zebra\">\r\n<tbody>\r\n\r\n<tr>\r\n\t<td width=\"70%\">\u0622\u0631\u062f\u0648\u06cc\u0646\u0648 UNO R3 \r\n<\/td>\r\n\t<td class=\"center\" width=\"10%\">\u00d7<\/td>\r\n    <td class=\"center\" width=\"10%\">1<\/td>\r\n\t<td class=\"center\" width=\"10%\"><a href=\"http:\/\/thecaferobot.com\/store\/arduino-uno-r3\" target=\"_blank\"><i class=\"fa fa-shopping-cart\" style=\"\"><\/i><\/a><\/td>\r\n<\/tr>\r\n<tr>\r\n\t<td width=\"70%\">\u0633\u0646\u0633\u0648\u0631 \u0632\u0627\u0648\u06cc\u0647\r\n<\/td>\r\n\t<td class=\"center\" width=\"10%\">\u00d7<\/td>\r\n    <td class=\"center\" width=\"10%\">1<\/td>\r\n\t<td class=\"center\" width=\"10%\"><a href=\"https:\/\/thecaferobot.com\/store\/tilt-sensor-switch-module-b-type\" target=\"_blank\"><i class=\"fa fa-shopping-cart\" style=\"\"><\/i><\/a><\/td>\r\n<\/tr>\r\n<tr>\r\n\t<td width=\"70%\">\u0633\u06cc\u0645 \u062c\u0627\u0645\u067e\u0631 \u0646\u0631\u06cc \u0628\u0647 \u0645\u0627\u062f\u06af\u06cc  \r\n<\/td>\r\n\t<td class=\"center\" width=\"10%\">\u00d7<\/td>\r\n    <td class=\"center\" width=\"10%\">1<\/td>\r\n\t<td class=\"center\" width=\"10%\"><a href=\"http:\/\/thecaferobot.com\/store\/40p-male-female-10cm-jumper-wire\" target=\"_blank\"><i class=\"fa fa-shopping-cart\" style=\"\"><\/i><\/a><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2e2f94b0 elementor-widget elementor-widget-heading\" data-id=\"2e2f94b0\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">\u0646\u0631\u0645 \u0627\u0641\u0632\u0627\u0631\u0647\u0627\u06cc \u0645\u0648\u0631\u062f \u0646\u06cc\u0627\u0632<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-75598aa1 elementor-widget elementor-widget-html\" data-id=\"75598aa1\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<div class=\"table-2\">\r\n<table width=\"100%\" class=\"zebra\">\r\n<tbody>\r\n\r\n<tr>\r\n\t<td width=\"90%\">\u0622\u0631\u062f\u0648\u06cc\u0646\u0648 IDE<\/td>\r\n\t<td class=\"center\" width=\"10%\"><a href=\"https:\/\/www.arduino.cc\/en\/Main\/Software\" target=\"_blank\"><i class=\"fa fa-info\" style=\"\"><\/i><\/a><\/td>\r\n<\/tr>\r\n\r\n\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6605a7ec elementor-widget elementor-widget-heading\" data-id=\"6605a7ec\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">\u0631\u0627\u0647 \u0627\u0646\u062f\u0627\u0632\u06cc \u0633\u0648\u0626\u06cc\u0686 \u06a9\u062c\u06cc \u0648 \u0632\u0627\u0648\u06cc\u0647 \u0628\u0627 \u0622\u0631\u062f\u0648\u06cc\u0646\u0648<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-57a210df elementor-widget elementor-widget-heading\" data-id=\"57a210df\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">\u06af\u0627\u0645 \u0627\u0648\u0644: \u0633\u06cc\u0645 \u0628\u0646\u062f\u06cc<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2da5a154 elementor-widget elementor-widget-text-editor\" data-id=\"2da5a154\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\">\n\t\t\t\t\u0645\u0637\u0627\u0628\u0642 \u0645\u062f\u0627\u0631 \u0632\u06cc\u0631\u060c \u0633\u0646\u0633\u0648\u0631 \u0631\u0627 \u0628\u0647 \u0622\u0631\u062f\u0648\u06cc\u0646\u0648 \u0648\u0635\u0644 \u06a9\u0646\u06cc\u062f.\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b54e7db elementor-widget elementor-widget-image\" data-id=\"b54e7db\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-image\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/Tilt-Switch-Circuit.jpg\" data-elementor-open-lightbox=\"yes\" data-elementor-lightbox-title=\"Tilt-Switch-Circuit.jpg\" e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MjAwNDQsInVybCI6Imh0dHBzOlwvXC90aGVjYWZlcm9ib3QuY29tXC9sZWFyblwvd3AtY29udGVudFwvdXBsb2Fkc1wvMjAyMFwvMTFcL1RpbHQtU3dpdGNoLUNpcmN1aXQuanBnIn0%3D\">\n\t\t\t\t\t\t\t<img width=\"800\" height=\"600\" src=\"https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/Tilt-Switch-Circuit.jpg\" class=\"attachment-large size-large\" alt=\"\u0633\u06cc\u0645 \u0628\u0646\u062f\u06cc \u0645\u062f\u0627\u0631 \u0627\u062a\u0635\u0627\u0644 \u0633\u0648\u0626\u06cc\u0686 \u06a9\u062c\u06cc \u0648 \u0632\u0627\u0648\u06cc\u0647 \u0628\u0647 \u0622\u0631\u062f\u0648\u06cc\u0646\u0648\" loading=\"lazy\" \/>\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-37c2a48e elementor-widget elementor-widget-heading\" data-id=\"37c2a48e\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">\u06af\u0627\u0645 \u062f\u0648\u0645: \u06a9\u062f<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-49d0e65b elementor-widget elementor-widget-text-editor\" data-id=\"49d0e65b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\">\n\t\t\t\t\u06a9\u062f \u0632\u06cc\u0631 \u0631\u0627 \u0631\u0648\u06cc \u0628\u0631\u062f \u0622\u0631\u062f\u0648\u06cc\u0646\u0648 \u0622\u067e\u0644\u0648\u062f \u06a9\u0646\u06cc\u062f. \u0627\u06cc\u0646 \u06a9\u062f \u0628\u0631 \u0627\u0633\u0627\u0633 \u0632\u0627\u0648\u06cc\u0647 \u0627\u06cc \u06a9\u0647 \u0633\u0646\u0633\u0648\u0631 \u0642\u0631\u0627\u0631 \u062f\u0627\u0631\u062f\u060c LED \u0631\u0648\u06cc \u0622\u0631\u062f\u0648\u06cc\u0646\u0648 \u0631\u0627 \u062e\u0627\u0645\u0648\u0634 \u0648 \u0631\u0648\u0634\u0646 \u0645\u06cc \u06a9\u0646\u062f.\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7f811694 elementor-widget elementor-widget-html\" data-id=\"7f811694\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<pre class=\"line-numbers lang-arduino\"><code>\/* Tilt Switch\r\n   Better Debouncer\r\n\r\n   This debouncing circuit is more rugged, and will work with tilt switches!\r\n\r\n   http:\/\/www.ladyada.net\/learn\/sensor\/tilt.html\r\n*\/\r\n\r\nint inPin = 2;         \/\/ Tilt Sensor\r\nint outPin = 13;       \/\/ LED Pin\r\n\r\nint LEDstate = HIGH;      \/\/ the current state of the output pin\r\nint reading;           \/\/ the current reading from the input pin\r\nint previous = LOW;    \/\/ the previous reading from the input pin\r\n\r\n\/\/ the following variables are long because the time, measured in miliseconds,\r\n\/\/ will quickly become a bigger number than can be stored in an int.\r\nlong time = 0;         \/\/ the last time the output pin was toggled\r\nlong debounce = 50;   \/\/ the debounce time, increase if the output flickers\r\n\r\nvoid setup()\r\n{\r\n  pinMode(inPin, INPUT);\r\n  digitalWrite(inPin, HIGH);   \/\/ turn on the built in pull-up resistor\r\n  pinMode(outPin, OUTPUT);\r\n}\r\n\r\nvoid loop()\r\n{\r\n  int switchstate;\r\n\r\n  reading = digitalRead(inPin);\r\n\r\n  \/\/ If the switch changed, due to bounce or pressing...\r\n  if (reading != previous) {\r\n    \/\/ reset the debouncing timer\r\n    time = millis();\r\n  }\r\n\r\n  if ((millis() - time) &gt; debounce) {\r\n    \/\/ whatever the switch is at, its been there for a long time\r\n    \/\/ so lets settle on it!\r\n    switchstate = reading;\r\n\r\n\r\n    if (switchstate == HIGH)\r\n      LEDstate = LOW;\r\n    else\r\n      LEDstate = HIGH;\r\n  }\r\n  digitalWrite(outPin, LEDstate);\r\n\r\n  \/\/ Save the last reading so we keep a running tally\r\n  previous = reading;\r\n}\r\n<\/code><\/pre>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/section>\r\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\u0648\u06cc\u0698\u06af\u06cc \u0647\u0627\u06cc \u0633\u0646\u0633\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u06a9\u062c\u06cc \u0648 \u0632\u0627\u0648\u06cc\u0647 \u0639\u0645\u0644\u06a9\u0631\u062f \u0627\u06cc\u0646 \u0633\u0646\u0633\u0648\u0631 \u0634\u0628\u06cc\u0647 \u06cc\u06a9 \u0633\u0648\u0626\u06cc\u0686 \u0645\u06cc \u0628\u0627\u0634\u062f. \u062f\u0627\u062e\u0644 \u0645\u062d\u0641\u0638\u0647 \u06cc \u0627\u0633\u062a\u0648\u0627\u0646\u0647 \u0627\u06cc \u0633\u0646\u0633\u0648\u0631\u060c 2 \u0633\u0627\u0686\u0645\u0647 \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f. \u0628\u0627 \u062a\u0648\u062c\u0647 \u0628\u0647 \u0646\u062d\u0648\u0647 \u06cc \u0642\u0631\u0627\u0631 \u06af\u06cc\u0631\u06cc \u0627\u06cc\u0646 \u062f\u0648 \u0633\u0627\u0686\u0645\u0647\u060c \u0633\u0648\u0626\u06cc\u0686 \u0642\u0637\u0639 \u0648 \u0648\u0635\u0644 \u0645\u06cc \u0634\u0648\u062f. \u0645\u0639\u0631\u0641\u06cc \u067e\u0627\u06cc\u0647 \u0647\u0627 (Pinout) \u0633\u0646\u0633\u0648\u0631 \u06a9\u062c\u06cc \u0645\u0627\u0698\u0648\u0644 \u0633\u0646\u0633\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u06a9\u062c\u06cc \u0648 \u0632\u0627\u0648\u06cc\u0647 \u062f\u0627\u0631\u0627\u06cc 3 [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":20039,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[932],"tags":[4628,4633],"platform":[1071],"bytype":[1075],"difficulty":[1077],"related_products":[3884],"featured_image_src":{"landsacpe":["https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/sen-01-006-teaser.jpg",1200,900,false],"list":["https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/sen-01-006-teaser.jpg",1200,900,false],"medium":["https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/sen-01-006-teaser.jpg",533,400,false],"full":["https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/sen-01-006-teaser.jpg",1200,900,false]},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v14.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u0622\u0645\u0648\u0632\u0634 \u0631\u0627\u0647 \u0627\u0646\u062f\u0627\u0632\u06cc \u0633\u0646\u0633\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0632\u0627\u0648\u06cc\u0647 \u0648 \u06a9\u062c\u06cc \u0628\u0627 \u0622\u0631\u062f\u0648\u06cc\u0646\u0648 - \u06a9\u0627\u0641\u0647 \u0631\u0628\u0627\u062a<\/title>\n<meta name=\"description\" content=\"\u062f\u0631 \u0622\u0645\u0648\u0632\u0634 \u0631\u0627\u0647 \u0627\u0646\u062f\u0627\u0632\u06cc \u0633\u0646\u0633\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0632\u0627\u0648\u06cc\u0647 \u0648 \u06a9\u062c\u06cc \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0622\u0631\u062f\u0648\u06cc\u0646\u0648 \u06cc\u0627\u062f \u0645\u06cc\u200c\u06af\u06cc\u0631\u06cc\u062f \u0686\u06af\u0648\u0646\u0647 \u0627\u0632 \u0633\u0646\u0633\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0632\u0627\u0648\u06cc\u0647 \u0648 \u06a9\u062c\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f \u0628\u0647 \u0647\u0645\u0631\u0627\u0647\u060c \u0645\u062b\u0627\u0644\" \/>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/\" \/>\n<meta property=\"og:locale\" content=\"fa_IR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u0622\u0645\u0648\u0632\u0634 \u0631\u0627\u0647 \u0627\u0646\u062f\u0627\u0632\u06cc \u0633\u0646\u0633\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0632\u0627\u0648\u06cc\u0647 \u0648 \u06a9\u062c\u06cc \u0628\u0627 \u0622\u0631\u062f\u0648\u06cc\u0646\u0648 - \u06a9\u0627\u0641\u0647 \u0631\u0628\u0627\u062a\" \/>\n<meta property=\"og:description\" content=\"\u062f\u0631 \u0622\u0645\u0648\u0632\u0634 \u0631\u0627\u0647 \u0627\u0646\u062f\u0627\u0632\u06cc \u0633\u0646\u0633\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0632\u0627\u0648\u06cc\u0647 \u0648 \u06a9\u062c\u06cc \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0622\u0631\u062f\u0648\u06cc\u0646\u0648 \u06cc\u0627\u062f \u0645\u06cc\u200c\u06af\u06cc\u0631\u06cc\u062f \u0686\u06af\u0648\u0646\u0647 \u0627\u0632 \u0633\u0646\u0633\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686 \u0632\u0627\u0648\u06cc\u0647 \u0648 \u06a9\u062c\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f \u0628\u0647 \u0647\u0645\u0631\u0627\u0647\u060c \u0645\u062b\u0627\u0644\" \/>\n<meta property=\"og:url\" content=\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/\" \/>\n<meta property=\"og:site_name\" content=\"\u06a9\u0627\u0641\u0647 \u0631\u0628\u0627\u062a\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-28T14:18:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-20T11:45:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/sen-01-006-teaser.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/thecaferobot.com\/learn\/#organization\",\"name\":\"\\u06a9\\u0627\\u0641\\u0647 \\u0631\\u0628\\u0627\\u062a\",\"url\":\"https:\/\/thecaferobot.com\/learn\/\",\"sameAs\":[],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/thecaferobot.com\/learn\/#logo\",\"inLanguage\":\"fa-IR\",\"url\":\"https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2018\/08\/Logo-small.png\",\"width\":250,\"height\":250,\"caption\":\"\\u06a9\\u0627\\u0641\\u0647 \\u0631\\u0628\\u0627\\u062a\"},\"image\":{\"@id\":\"https:\/\/thecaferobot.com\/learn\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/thecaferobot.com\/learn\/#website\",\"url\":\"https:\/\/thecaferobot.com\/learn\/\",\"name\":\"\\u06a9\\u0627\\u0641\\u0647 \\u0631\\u0628\\u0627\\u062a\",\"description\":\"\\u0622\\u0645\\u0648\\u0632\\u0634 \\u0627\\u0644\\u06a9\\u062a\\u0631\\u0648\\u0646\\u06cc\\u06a9\\u060c \\u0631\\u0628\\u0627\\u062a\\u06cc\\u06a9\\u060c \\u0622\\u0631\\u062f\\u0648\\u06cc\\u0646\\u0648 \\u0648 \\u0631\\u0633\\u067e\\u0628\\u0631\\u06cc \\u067e\\u0627\\u06cc\",\"publisher\":{\"@id\":\"https:\/\/thecaferobot.com\/learn\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/thecaferobot.com\/learn\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"fa-IR\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/#primaryimage\",\"inLanguage\":\"fa-IR\",\"url\":\"https:\/\/thecaferobot.com\/learn\/wp-content\/uploads\/2020\/11\/sen-01-006-teaser.jpg\",\"width\":1200,\"height\":900},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/#webpage\",\"url\":\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/\",\"name\":\"\\u0622\\u0645\\u0648\\u0632\\u0634 \\u0631\\u0627\\u0647 \\u0627\\u0646\\u062f\\u0627\\u0632\\u06cc \\u0633\\u0646\\u0633\\u0648\\u0631 \\u0633\\u0648\\u0626\\u06cc\\u0686 \\u0632\\u0627\\u0648\\u06cc\\u0647 \\u0648 \\u06a9\\u062c\\u06cc \\u0628\\u0627 \\u0622\\u0631\\u062f\\u0648\\u06cc\\u0646\\u0648 - \\u06a9\\u0627\\u0641\\u0647 \\u0631\\u0628\\u0627\\u062a\",\"isPartOf\":{\"@id\":\"https:\/\/thecaferobot.com\/learn\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/#primaryimage\"},\"datePublished\":\"2020-11-28T14:18:15+00:00\",\"dateModified\":\"2021-06-20T11:45:57+00:00\",\"description\":\"\\u062f\\u0631 \\u0622\\u0645\\u0648\\u0632\\u0634 \\u0631\\u0627\\u0647 \\u0627\\u0646\\u062f\\u0627\\u0632\\u06cc \\u0633\\u0646\\u0633\\u0648\\u0631 \\u0633\\u0648\\u0626\\u06cc\\u0686 \\u0632\\u0627\\u0648\\u06cc\\u0647 \\u0648 \\u06a9\\u062c\\u06cc \\u0628\\u0627 \\u0627\\u0633\\u062a\\u0641\\u0627\\u062f\\u0647 \\u0627\\u0632 \\u0622\\u0631\\u062f\\u0648\\u06cc\\u0646\\u0648 \\u06cc\\u0627\\u062f \\u0645\\u06cc\\u200c\\u06af\\u06cc\\u0631\\u06cc\\u062f \\u0686\\u06af\\u0648\\u0646\\u0647 \\u0627\\u0632 \\u0633\\u0646\\u0633\\u0648\\u0631 \\u0633\\u0648\\u0626\\u06cc\\u0686 \\u0632\\u0627\\u0648\\u06cc\\u0647 \\u0648 \\u06a9\\u062c\\u06cc \\u0627\\u0633\\u062a\\u0641\\u0627\\u062f\\u0647 \\u06a9\\u0646\\u06cc\\u062f \\u0628\\u0647 \\u0647\\u0645\\u0631\\u0627\\u0647\\u060c \\u0645\\u062b\\u0627\\u0644\",\"inLanguage\":\"fa-IR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/\"]}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/#webpage\"},\"author\":{\"@id\":\"https:\/\/thecaferobot.com\/learn\/#\/schema\/person\/90df17e0df9d3c90563c270ae65ec3fc\"},\"headline\":\"\\u0622\\u0645\\u0648\\u0632\\u0634 \\u0631\\u0627\\u0647 \\u0627\\u0646\\u062f\\u0627\\u0632\\u06cc \\u0633\\u0646\\u0633\\u0648\\u0631 \\u0633\\u0648\\u0626\\u06cc\\u0686 \\u0632\\u0627\\u0648\\u06cc\\u0647 \\u0648 \\u06a9\\u062c\\u06cc \\u0628\\u0627 \\u0622\\u0631\\u062f\\u0648\\u06cc\\u0646\\u0648\",\"datePublished\":\"2020-11-28T14:18:15+00:00\",\"dateModified\":\"2021-06-20T11:45:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/#webpage\"},\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/thecaferobot.com\/learn\/#organization\"},\"image\":{\"@id\":\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/#primaryimage\"},\"keywords\":\"\\u0632\\u0627\\u0648\\u06cc\\u0647,\\u0644\\u0631\\u0632\\u0634\",\"articleSection\":\"\\u0633\\u0646\\u0633\\u0648\\u0631\\u0647\\u0627\",\"inLanguage\":\"fa-IR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/thecaferobot.com\/learn\/interfacing-tilt-switch-sensor-with-arduino\/#respond\"]}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/thecaferobot.com\/learn\/#\/schema\/person\/90df17e0df9d3c90563c270ae65ec3fc\",\"name\":\"\\u0645\\u062d\\u0645\\u062f\\u0631\\u0636\\u0627 \\u0627\\u06a9\\u0628\\u0631\\u06cc\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/thecaferobot.com\/learn\/#personlogo\",\"inLanguage\":\"fa-IR\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a1f89f4484a071b6569e017dc3507ee1?s=96&d=mm&r=g\",\"caption\":\"\\u0645\\u062d\\u0645\\u062f\\u0631\\u0636\\u0627 \\u0627\\u06a9\\u0628\\u0631\\u06cc\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","_links":{"self":[{"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/posts\/20038"}],"collection":[{"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/comments?post=20038"}],"version-history":[{"count":6,"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/posts\/20038\/revisions"}],"predecessor-version":[{"id":24934,"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/posts\/20038\/revisions\/24934"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/media\/20039"}],"wp:attachment":[{"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/media?parent=20038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/categories?post=20038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/tags?post=20038"},{"taxonomy":"platform","embeddable":true,"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/platform?post=20038"},{"taxonomy":"bytype","embeddable":true,"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/bytype?post=20038"},{"taxonomy":"difficulty","embeddable":true,"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/difficulty?post=20038"},{"taxonomy":"related_products","embeddable":true,"href":"https:\/\/thecaferobot.com\/learn\/wp-json\/wp\/v2\/related_products?post=20038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}