I think the issue is that you execute this
if (SwitchState1 == LOW) // Lower limit switch
{
digitalWrite(DOWN, LOW);
delay(10);
digitalWrite(UP, HIGH);
delay(200);
digitalWrite(UP, LOW);
delay(10);
}
if (SwitchState2 == LOW) //Upper limit switch
{
digitalWrite(UP, LOW);
delay(10);
digitalWrite(DOWN, HIGH);
delay(200);
digitalWrite(DOWN, LOW);
delay(10);
}
only once, when you have received something from the RC. so you get your motor going but since you are not receiving data anymore, you don't do your limit check. you need to move that part of the code out of the englobing if statement
also the
digitalWrite(DOWN, LOW);
delay(10);
when you hit the top switch is probably not needed; if you hit the top then you were not moving down and thus DOWN was LOW anyway already. you can probably get rid of it. same for the other one.
Also for this in the switch case
digitalWrite(UP, HIGH);
delay(100);
digitalWrite(DOWN, LOW);
delay(100);
why do you need the delay(100) ? get rid of them.
so you have nice #define at the beginning (switch_2ledBlueON) and then you don't use them in you switch case ?
this is how getReceivedValue is defined
unsigned long getReceivedValue();
why do you store the value into a signed long?
unsigned longs won't store negative numbers, making their range from 0 to 4,294,967,295 (2^32 - 1) whereas long store values from -2,147,483,648 to 2,147,483,647.
Looks like the values you expect are within range and won't overflow but this could be a source of error.
the #define at the beginning (if you were to use them) should also instruct the compiler about the format and should read#define switch_2ledBlueON 2214824882UL
The UL at the end tells the compiler what type of data to use when it will see that value later in the code.