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