Proofing code-IRremote servo controller issues

Hello all,
I have this code I've made and it used to work. Now i need to have someone tell me what I've done to make this not work. When I added the attach function in the If statements for the 360servos the program ignores all the other and just cycles thru the function without the remote being pushed. When I remove that from the if statement it does nothing. Also I m using the IDE v2.0 which has porting issue on my W11 pro box but my work around was to unplug from the usb then close the ide then plug the usb in watch for it in the device manager then open the IDE and hit upload. Anyway the program is supposed to work if you command the ir code to a function to move a servo. Simple enough right. So if anyone can is a coding error and help me fix this it would instruct me in the reason for next time. The project is for my grandsons robot. I have on purpose left out some coding for future add on's.

\\code below as is\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

 #include <IRremote.h>
#include <Servo.h>
 
//must use arduino mega for all servos to work or drop the head servo for uno board
int IRpin=3;// IR Receiver Input to pin a PWM ~ pin
//int srvHead=5;//head servo
int srvLtArm=5;//left arm
int srvLtHnd=6;//Left Hand Gripper
int srvRtArm=9;//right arm
int srvLtLg=10;//left leg pwm~
int srvRtLg=11;//right leg
int eyes=13;//Green LEDS in head , flash when commands sent.

//Servo srvHead1;
Servo srvLtArm1;
Servo srvRtArm1;
Servo srvLtLg1;
Servo srvRtLg1;
Servo srvLtHnd1;

IRrecv irrecv(IRpin);

decode_results results;

void setup() {

irrecv.enableIRIn(); 
 

pinMode(eyes, OUTPUT);
//pinMode(srvHead, OUTPUT); //add if you have a bigger board 
pinMode(srvLtArm, OUTPUT);
pinMode(srvRtArm, OUTPUT);
pinMode(srvLtLg, OUTPUT);
pinMode(srvRtLg, OUTPUT);
pinMode(srvLtHnd, OUTPUT);

Serial.begin(9600); //enable if plugged into pc to troubleshoot code

//srvHead1.attach();
srvLtArm1.attach(5);
srvLtHnd1.attach(6);
srvRtArm1.attach(9);

}

void loop() {

if (irrecv.decode(&results)) {

   Serial.println(results.value, HEX);
}

irrecv.resume();

if (results.value==0xF30CFF00); // IR button 1 left up
{ 
srvLtArm1.write(170);//(180full up) is just the 0 mid point no variable
delay(15);
}
if (results.value==0xBD42FF00);  //IR button 7 left down
{
srvLtArm1.write(0);
delay(15);
}
if (results.value==0xA15EFF00); //IR button 3 right up
{
srvRtArm1.write(170);
delay(15);
}
if (results.value==0xB54AFF00); //IR button 9 right down
{
srvRtArm1.write(0);
delay(15);
}
//if (cmd.value==0xFFE21D) //this head func copy leg left and right cmds
//{
//srvHead1.write(0);
//delay(15);
//}
//if (cmd.value==0xFF02FD) //this head func copy leg left and right cmds
//{
//srvHead1.write(180);
//delay(15);
//}
if (results.value==0xF807FF00); //IR button downarrow robot reverse 360rot servos
{
srvLtLg1.attach(10);
srvRtLg1.attach(11);
srvLtLg1.write(0);//CW rot full speed
srvRtLg1.write(0);
delay(1000);
srvLtLg1.detach();
srvRtLg1.detach();
}
if (results.value==0xB847FF00); //IR button Func/Stop robot forwards 360rot servos
{
srvLtLg1.attach(10);
srvRtLg1.attach(11);
srvLtLg1.write(90);//stops the motor 
srvRtLg1.write(90);
delay(1000);
srvLtLg1.detach();
srvRtLg1.detach();
}
if (results.value==0xF609FF00); //IR button uparrow robot forward 360rot servos
{
srvLtLg1.attach(10);
srvRtLg1.attach(11);
srvLtLg1.write(180);//CCW rot full speed
srvRtLg1.write(180);
delay(1000);
srvLtLg1.detach();
srvRtLg1.detach();
}
if (results.value==0xBB44FF000); //IR button rewind left turn
{
srvLtLg1.attach(10);
srvRtLg1.attach(11);
srvLtLg1.write(100);//CCW rot
srvRtLg1.write(85);//CW rot
delay(1000);
srvLtLg1.detach();
srvRtLg1.detach();
}
if (results.value==0xBC43FF00); //IR buttonIR button FastForwd right turn
{
srvLtLg1.attach(10);
srvRtLg1.attach(11);
srvLtLg1.write(85);//CW rot
srvRtLg1.write(100);//CCW rot
delay(1000);
srvLtLg1.detach();
srvRtLg1.detach();
}

IrReceiver.resume();
}

All of your if statements end in semicolons (;). They should not. See the if structure reference.

Read the forum guidelines](How to get the best out of this forum) to see how to properly post code and some information on how to get the most from this forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

You can go back and fix your original post by highlighting the code and clicking the </> in the menu bar.
code tags new

thanks will do

Well done, thank you. But still needs formatting.

See my edit to my original answer. Fix those if statements and try again.

Thats what I need help with. Not sure what syntax to use to fix.

The if statements rarely, if ever, have semi colons at the ends.

if (results.value==0xF30CFF00); >>>>> NO.

if (results.value==0xF30CFF00) >>>>>> yes

So just remove the semicolons from any of the if statements.

I might use a switch case structure instead of if statements in that code.

I can't believe I didn't notice that. WOW ....ya I was wondering about the case function as well. I might still do that once I'm happy with the code working as is. I had issue's with the decode function not working well and was fixing that mess to. Thanks

You are welcome.

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