1

So I basically tried to control a Servo motor with an IR Remote. I'm a complete newbie in arduino programming but I just took some things from other scripts and tried them out until It worked, and it kinda did but my main problem is that as soon as I press a button the action is exectuted but the command like left arrow on the remote control just spams over and over again so I cannot have an action after that one

`

#include "IRremote.h"
#include "IR.h"
#include <Servo.h>

int receiver = 11;


IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;      // create instance of 'decode_results'
Servo myservo;

void setup() {
  Serial.begin(9600);
  Serial.println("IR Receiver Button Decode");
  irrecv.enableIRIn();
  myservo.attach(9);
  myservo.write(0);
}

void loop()
{
if (irrecv.decode(&results)) 
 {
   //  irrecv.resume();   // Receive the next value
  // }
  //if (results.value == 0xFF629D)  // change according to your IR remote button number
  //  {
    //  myservo.write(0);
      //delay(15);
   // }
    //if (results.value == 0xFF629D)  // change according  to your IR remote button number
    //{
     // myservo.write(30);
    //delay(15);
    //}

      switch(results.value)
  {
  case 0xFFA25D: Serial.println("POWER"); break;
  case 0xFFE21D: Serial.println("FUNC/STOP"); break;
  case 0xFF629D: Serial.println("VOL+"); break;
  case 0xFF22DD: Serial.println("FAST BACK");
  myservo.write(90);
  delay(15);
  break;
  case 0xFF02FD: Serial.println("PAUSE");    break;
  case 0xFFC23D: Serial.println("FAST FORWARD");
  break;
  case 0xFFE01F: Serial.println("DOWN");    break;
  case 0xFFA857: Serial.println("VOL-");    break;
  case 0xFF906F: Serial.println("UP");    break;
  case 0xFF9867: Serial.println("EQ");    break;
  case 0xFFB04F: Serial.println("ST/REPT");    break;
  case 0xFF6897: Serial.println("0");    break;
  case 0xFF30CF: Serial.println("1");    break;
  case 0xFF18E7: Serial.println("2");    break;
  case 0xFF7A85: Serial.println("3");    break;
  case 0xFF10EF: Serial.println("4");    break;
  case 0xFF38C7: Serial.println("5");    break;
  case 0xFF5AA5: Serial.println("6");    break;
  case 0xFF42BD: Serial.println("7");    break;
  case 0xFF4AB5: Serial.println("8");    break;
  case 0xFF52AD: Serial.println("9");    break;
  case 0xFFFFFFFF: Serial.println(" REPEAT");break;  
  default: 
    Serial.println(" other button   ");`

That's my code, and whenever I press like Fast Back I can't do anything else and the Serial Monitor is just full of Fast Back

3
  • Put back in the irrecv.resume() that you commented out?
    – Majenko
    Oct 27 '20 at 17:33
  • what happens if you press VOL+?
    – jsotola
    Oct 27 '20 at 17:35
  • @Majenko Thank you very much, ther commented out one acutally had nothing to do with it but I had to add one at the end of the switch
    – HallOfRain
    Oct 27 '20 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.