{"id":131,"date":"2011-11-28T18:08:45","date_gmt":"2011-11-28T18:08:45","guid":{"rendered":"https:\/\/gamadiyo.com\/blog\/?p=131"},"modified":"2011-11-28T21:00:56","modified_gmt":"2011-11-28T21:00:56","slug":"arduino-webswitch","status":"publish","type":"post","link":"https:\/\/gamadiyo.com\/blog\/?p=131","title":{"rendered":"Arduino: WebSwitch"},"content":{"rendered":"<p>I found a remote control switch by Stanley at Bed Bath &amp; Beyond for $10. It lets you turn on\/off 3 electrical outlets with a small remote control. Its similar to <a href=\"http:\/\/www.amazon.com\/Stanley-31164-Wireless-Control-Transmitter\/dp\/B0020ML762\" target=\"_blank\">this one<\/a> on Amazon. I was able to open the remote easily and get to the buttons. I soldered couple of wires to the end of the terminals and was able to extend it out to the side of the remote. I connected the wires to a transistor to the\u00c2\u00a0emitter\u00c2\u00a0and collector. Used a 10k resistor to ground it to Arduino&#8217;s ground. Pin 7 &amp; 8 were connected to the base of the NPN transistor (2N3904).<\/p>\n\n\t\t<style type=\"text\/css\">\n\t\t\t#gallery-1 {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: 33%;\n\t\t\t}\n\t\t\t#gallery-1 img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t\t\/* see gallery_shortcode() in wp-includes\/media.php *\/\n\t\t<\/style>\n\t\t<div id='gallery-1' class='gallery galleryid-131 gallery-columns-3 gallery-size-thumbnail'><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/gamadiyo.com\/blog\/?attachment_id=132'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/gamadiyo.com\/blog\/wp-content\/uploads\/2011\/11\/WebSwitch-Sketch-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/gamadiyo.com\/blog\/?attachment_id=134'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/gamadiyo.com\/blog\/wp-content\/uploads\/2011\/11\/IMG_0862-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/gamadiyo.com\/blog\/?attachment_id=135'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/gamadiyo.com\/blog\/wp-content\/uploads\/2011\/11\/IMG_0863-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><br style=\"clear: both\" \/>\n\t\t<\/div>\n\n<p>At first, I tested it with serial communication. The code would listen for a &#8220;1&#8221; or a &#8220;0&#8221; from the serial monitor and send a HIGH\/LOW to pin 7 or pin 8 (1 for ON and 0 for OFF). Once I got that to work, I changed the code so it will read a index.php on a webserver. The index.php is set to read a txt file which has a 0 or 1 written to it by another PHP file. &#8220;On.php&#8221; will write a &#8220;1&#8221; to the txt file and &#8220;Off.php&#8221; will write a &#8220;0&#8221; to the txt file. When Arduino gets the information, it activates the appropriate pin to activate the transistor for 1 second.<\/p>\n<p><a href=\"https:\/\/gamadiyo.com\/blog\/wp-content\/uploads\/2011\/11\/RemoteSwitchWeb.txt\">RemoteSwitchWeb<\/a> (code)<a href=\"https:\/\/gamadiyo.com\/blog\/wp-content\/uploads\/2011\/11\/RemoteSwitchWeb.txt\"><br \/>\n<\/a><a href=\"https:\/\/gamadiyo.com\/blog\/wp-content\/uploads\/2011\/11\/php-files.zip\">php files<\/a>\u00c2\u00a0(copy these files to root of php server)<\/p>\n\n<div class=\"youtube-embed\" itemprop=\"video\" itemscope itemtype=\"https:\/\/schema.org\/VideoObject\">\n\t<meta itemprop=\"url\" content=\"https:\/\/www.youtube.com\/v\/mm8HlsMBFt8\" \/>\n\t<meta itemprop=\"name\" content=\"Arduino: WebSwitch\" \/>\n\t<meta itemprop=\"description\" content=\"Arduino: WebSwitch\" \/>\n\t<meta itemprop=\"uploadDate\" content=\"2011-11-28T18:08:45-05:00\" \/>\n\t<meta itemprop=\"thumbnailUrl\" content=\"https:\/\/i.ytimg.com\/vi\/mm8HlsMBFt8\/default.jpg\" \/>\n\t<meta itemprop=\"embedUrl\" content=\"https:\/\/www.youtube.com\/embed\/mm8HlsMBFt8\" \/>\n\t<meta itemprop=\"height\" content=\"276\" \/>\n\t<meta itemprop=\"width\" content=\"490\" \/>\n\t<iframe loading=\"lazy\" style=\"border: 0;\" class=\"youtube-player\" width=\"490\" height=\"276\" src=\"https:\/\/www.youtube.com\/embed\/mm8HlsMBFt8?modestbranding=1&fs=0&rel=0\"><\/iframe>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>I found a remote control switch by Stanley at Bed Bath &amp; Beyond for $10. It lets you turn on\/off 3 electrical outlets with a small remote control. Its similar to this one on Amazon. I was able to open the remote easily and get to the buttons. I soldered couple of wires to the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-arduino-2"],"_links":{"self":[{"href":"https:\/\/gamadiyo.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gamadiyo.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gamadiyo.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gamadiyo.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gamadiyo.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=131"}],"version-history":[{"count":0,"href":"https:\/\/gamadiyo.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions"}],"wp:attachment":[{"href":"https:\/\/gamadiyo.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gamadiyo.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gamadiyo.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}