#include <IRremote.h> //Include remote library
#include <Servo.h> //Include servo library
//Define each of the necessary buttons as their respective codes
#define play_button 765
#define off_button 41565
#define rewind_button 8925
#define fastforward_button 49725
#define funcstop_button 57885
#define zero_button 26775
int receiver_pin = 2; //Initialize pin 2 for IR receiver
int motor_right = 8; //Initialize pin 8 for motor to spin forward
int motor_left = 12; //Initialize pin 12 for motor to spin backward
int servo_pin = 5; //Initialize pin 5 for the servo
int degree = 90; //define degree variable to be 90 at start
Servo Servo1; //Create a servo object called Servo1
IRrecv receiver(receiver_pin); //Arduino will take output of IR receiver from pin 2
decode_results output; //Decode the results from the IR receiver
void setup()
{
Serial.begin(9600);
receiver.enableIRIn(); // Start to take the output from IR receiver
//Setup the two motor pins as outputs and setup the servo pin
pinMode(motor_right, OUTPUT);
pinMode(motor_left, OUTPUT);
Servo1.attach(servo_pin);
}
void loop()
{
if (receiver.decode(&output)) //if receiver output is one of the previously defined values
{
unsigned int value = output.value;
switch(value) //switch the function of the circuit
//based on the output value from the IR receiver
{
case play_button: //spin motor forward when play button pressed for 3 sec
digitalWrite(motor_right,HIGH);
delay(1000);
digitalWrite(motor_right,LOW);
digitalWrite(motor_left,LOW);
break;
case funcstop_button: //Spin motor backward when func/stop button pressed for 3 sec
digitalWrite(motor_left,HIGH);
delay(3000);
digitalWrite(motor_right,LOW);
digitalWrite(motor_left,LOW);
break;
case off_button: //Stop motor when off button pressed
digitalWrite(motor_right,LOW);
digitalWrite(motor_left,LOW);
break;
case rewind_button: //Increase degree by 10 when rewind button pressed
degree+=10;
if(degree>180) degree=180;
Servo1.write(degree);
break;
case fastforward_button: //Decrease degree by 10 when fast forward button pressed
degree-=10;
if(degree<0) degree=0;
Servo1.write(degree);
break;
case zero_button: //Set servo back to 90 degrees when zero button pressed
degree=90;
Servo1.write(degree);
break;
//where's your default?
} //switch
} //if
} //end of loop routine
receiver.resume(); //Resume communication with IR receiver”
// where is your main() ????
//e.g void main ( void) or int main (void)
// {
// setup();
// loop();
// do something else;
// }
If you only posted a code snippet please post the rest of your code, I haven't programmed an arduino but do have some experience with the C programming language