Arduino Servo and Remote setup

Arduino script

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.

Here is the setup for the board:

The IR sensor I have was pinned out just a little different then this one in the graphic but since it’s unlabled, read the description below and I will go into further details.

Lets, start with the Infrared Sensor:
3.3v to IR sensor power
GND to IR sensor ground
Pin 9 from the top block to IR I/O

Now the Servo:
5v to mini servo power
GND to mini servo Ground
pin 11 from top block to Servo I/O

First you need to find what “numbers” 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:

/*The IR sensor'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 <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(&results))    {     Serial.println(results.value, DEC); // Print the Serial 'results.value'     irrecv.resume();   // Receive the next value   }}

as you touch the buttons on your remote, the infrared light should start flickering. In the Arduino software select “serial monitor” and view the hex value spit out for each button push, record what you do in a notepad. Say for instance if you touch “1” and it spits out 12345678, record that. Then when you hit “2”, 12387645 record that. It’s important because you use those button codes in the final software.

#include <IRremote.h>
#include <Servo.h>
int IRpin = 11;  // pin for the IR sensor
IRrecv irrecv(IRpin);
decode_results results;
Servo myservo;
void setup()
{
 Serial.begin(9600);
 irrecv.enableIRIn(); // Start the receiver
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}
void loop() 
{
 if (irrecv.decode(&results)) 
   {
     irrecv.resume();   // Receive the next value
   }
  if (results.value == 33441975)  // change according to your IR remote button number
    {
      myservo.write(0);
      delay(15);
    }
    if (results.value == 33446055)  // change according  to your IR remote button number
    {
      myservo.write(30);
    delay(15);
    }
    
}     

This script is old and does not handle “Results” 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.

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.