servomotor/IRcontrol

Hello,
I'm new to programming and I really need your help!
I would absolutely like to use the remote control in my code but I don't know how to use it! Here is the code:

#include <Servo.h> // we include the library to drive a servo motor

Servo myServo; // we create the myServo object

void setup()
{
    myServo.attach(9); // we define the Pin used by the servomotor
}

voidloop()
{
    for (int position = 0; position <=360; position ++){ // we create a position variable that takes values ​​between 0 and 180 degrees
        myServo.write(position); // the arm of the servomotor takes the position of the position variable
        delay(30); // we wait 15 milliseconds
    }

    for (int position = 360; position >=0; position --){ // this time the variable position goes from 180 to 0°
        myServo.write(position); // the arm of the servomotor takes the position of the position variable
        delay(15); // the arm of the servomotor takes the position of the position variable
        while(1);
    }
}

What I would like to do is that if the button 0 of the remote control is pressed then it would be necessary to launch the code above! it's a bit much what I'm asking because you have to include #include <Servo.h> but also the #include <IRremote.h> but I don't think it should be complicated. I patiently await your response! I hope you will be up to it to meet my desires.
Thanks for your help!
Ristouf

Have you looked at the IR library example code, and tried some of the examples?

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.

It will help you get the best out of the forum in the future.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.