How Can I set angle of servo with IR remote?

Hey mates,

I am very new in this community and I would like to ask you how code should be written if you wants to set angle of a servo from IR remote. Despite my many tries and goggling, I have been unable to find any particular solution and seems like no body has done this yet.

Any idea how code should be written for this kindaa project?

Thanks

Get the library: https://github.com/shirriff/Arduino-IRremote

as each button sends a loooong code, add : byte keycode=results.value & 255; // mask to 8 bit

find code for each key u want to use, picture shows on of my remotes…
You can then use a key to incr./decr. servo angle or goto specific angle.

knut_ny: Get the library: https://github.com/shirriff/Arduino-IRremote

as each button sends a loooong code, add : byte keycode=results.value & 255; // mask to 8 bit

find code for each key u want to use, picture shows on of my remotes.. You can then use a key to incr./decr. servo angle or goto specific angle.

Thank you so much. I did as you said. Now I have values of each key of IR remote. However I cannot figure out how my main body program should be written ? I thought I would store values from IR remote in a array and use array element to write servo angle but there are problems. angle could differ from 0 to 180/360. I want to make sure that I should be angle to write any angle. Lets say use Play key as enter key . Program should write any store value to servo once enter key is pressed? Make sense? Cnnot figure out program tho

Thank you

..post the code u've got. I'll make additions to it..

Hello Guys,

I have been only successful in converting values to 1-9 digits but I still dont know how to further store them and use them to write angle for servo. Once the values is written to servo, it should automatically clear itself in order to receive new values and use them to write angle again.

Thank you

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





int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
Servo myservo;
int servoPin = 9;



#define EnterKey 1386468383
#define k1 2534850111 
#define k2  1033561079
#define k3 1635910171
#define k4 2351064443
#define k5 1217346747
#define k6 71952287
#define k7 851901943
#define k8 465573243
#define k9 1053031451
#define Zero 3238126971
int digit;





void setup()
{
	irrecv.enableIRIn();
	myservo.attach(servoPin);
	myservo.write(0);
	Serial.begin(9600);

}

void loop()
{

	if (irrecv.decode(&results))
	{
		unsigned long val2 = results.value;
		int digits = conversion(val2);

		if (digits != 400){
			
			Serial.println(digits);
			delay(200);
			irrecv.resume();
		}
		else{
			delay(100);
			irrecv.resume();
		}


	}
}


int conversion(unsigned long IRval)
{
	switch (IRval)
	{
	case EnterKey:
		digit = 200;
		break;
	case k1:
		digit = 1;
		break;
	case k2:
		digit = 2;
		break;
	case k3:
		digit = 3;
		break;
	case k4:
		digit = 4;
		break;
	case k5:
		digit = 5;
		break;
	case k6:
		digit = 6;
		break;
	case k7:
		digit = 7;
		break;
	case k8:
		digit = 8;
		break;
	case k9:
		digit = 9;
		break;
	case Zero:
		digit = 0;
		break;
	default:
		digit = 400;
		break;
	}

	return digit;

}