{"id":19,"date":"2022-08-22T19:48:00","date_gmt":"2022-08-22T19:48:00","guid":{"rendered":"https:\/\/www.glencoulson.com\/?p=19"},"modified":"2024-12-04T22:14:36","modified_gmt":"2024-12-04T22:14:36","slug":"arduino-servo-and-remote-control-setup","status":"publish","type":"post","link":"https:\/\/www.glencoulson.com\/index.php\/2022\/08\/22\/arduino-servo-and-remote-control-setup\/","title":{"rendered":"Arduino Servo and Remote Control setup"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I went and found a script online to program an Arduino board to power a servo via remote control to run a small studio setup for remote camera 1, camera 2 selection. I have an elegoo256 board which is overkill for this project, but great for a test, so I have ordered an Arduino UNO R3 for final placement.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the setup for the board:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"676\" height=\"388\" src=\"https:\/\/www.glencoulson.com\/wp-content\/uploads\/2024\/12\/arduinosetup.png\" alt=\"\" class=\"wp-image-20\" srcset=\"https:\/\/www.glencoulson.com\/wp-content\/uploads\/2024\/12\/arduinosetup.png 676w, https:\/\/www.glencoulson.com\/wp-content\/uploads\/2024\/12\/arduinosetup-300x172.png 300w\" sizes=\"auto, (max-width: 676px) 100vw, 676px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The IR sensor I have was pinned out just a little different then this one in the graphic but since it\u2019s unlabled, read the description below and I will go into further details.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Lets, start with the Infrared Sensor:<br>3.3v to IR sensor power<br>GND to IR sensor ground<br>Pin 9 from the top block to IR I\/O<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now the Servo:<br>5v to mini servo power<br>GND to mini servo Ground<br>pin 11 from top block to Servo I\/O<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First you need to find what \u201cnumbers\u201d are being transmitted via IR remote. you can do that with this code, load it into the Arduino software and upload it to the board:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\/*The IR sensor&#8217;s pins are attached to Arduino as so:Pin 1 to Vout (pin 11 on Arduino)Pin 2 to GNDPin 3 to Vcc (+5v from Arduino)*\/#include &lt;IRremote.h>int IRpin = 11;IRrecv irrecv(IRpin);decode_results results;void setup(){Serial.begin(9600); irrecv.enableIRIn(); \/\/ Start the receiver}void loop() { if (irrecv.decode(&amp;results)) { Serial.println(results.value, DEC); \/\/ Print the Serial &#8216;results.value&#8217; irrecv.resume(); \/\/ Receive the next value }}<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">as you touch the buttons on your remote, the infrared light should start flickering. In the Arduino software select \u201cserial monitor\u201d and view the hex value spit out for each button push, record what you do in a notepad. Say for instance if you touch \u201c1\u201d and it spits out 12345678, record that. Then when you hit \u201c2\u201d, 12387645 record that. It\u2019s important because you use those button codes in the final software.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;IRremote.h>\n#include &lt;Servo.h>\nint IRpin = 11;  \/\/ pin for the IR sensor\nIRrecv irrecv(IRpin);\ndecode_results results;\nServo myservo;\nvoid setup()\n{\n Serial.begin(9600);\n irrecv.enableIRIn(); \/\/ Start the receiver\n myservo.attach(9);  \/\/ attaches the servo on pin 9 to the servo object\n}\nvoid loop() \n{\n if (irrecv.decode(&amp;results)) \n   {\n     irrecv.resume();   \/\/ Receive the next value\n   }\n  if (results.value == 33441975)  \/\/ change according to your IR remote button number\n    {\n      myservo.write(0);\n      delay(15);\n    }\n    if (results.value == 33446055)  \/\/ change according  to your IR remote button number\n    {\n      myservo.write(30);\n    delay(15);\n    }\n    \n}     <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This script is old and does not handle \u201cResults\u201d well. I need to revisit this and re-code it when I have time. Change results.value entries in the script to match the hex output you recorded from your earlier button pushes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next up, I need to create a bracket that will hold the servo and push some small rods that physically click the button on the board. It would be better to find a less mechanical solution but since this production board is not my own, I will not look for an electronic trigger from this Arduino solution right now.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I went and found a script online to program an Arduino board to power a servo via remote control to run a small studio setup for remote camera 1, camera 2 selection. I have an elegoo256 board which is overkill for this project, but great for a test, so I have ordered an Arduino UNO [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":22,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7,5,6,8],"class_list":["post-19","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-arduino","tag-computers","tag-electronics","tag-production"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":1,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"predecessor-version":[{"id":21,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/posts\/19\/revisions\/21"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/media\/22"}],"wp:attachment":[{"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}