how do i tell to the edurc when the remote is on.

I have created an autonomous mode, I pasted it in the user_routines.c, in the part that says /add your code here/, well, it works.
Now i want to find a way to initialize it only when my remote control is off, and stop it when is on.
I tried:
if (PWM_n1 = PWM_n2 = 0) /where the pwm_n# is the alias given to the/
{ the whole rutine /* remote inputs */
but that does not make it work.
Is there a way i can tell the robot to initialize it when the remote is off? :confused:
i will be glad if anybody can help me.

“if (PWM_n1 = PWM_n2 = 0)” is not what you want. That says “set PWM_n2 equal to zero, and then set PWM_n1 equal to PWM_n2”. (Actually, it sets PWM_n1 equal to the value of the expression “PWM_n2 = 0” which happens to be the value assigned to PWM_n2.) The value of the expression “(PWM_n1 = PWM_n2 = 0)” is zero (which is false, by definition), so the next statement will never get executed.

I guess what you want is “if (PWM_n1 == 0 && PWM_n2 == 0)”

you might be tempted to try “if (PWM_n1 == PWM_n2 == 0)” which is incorrect also. This is going to compare PWM_n1 with the boolean expression “PWM_n2 == 0”, so your conditional statement will be executed only if PWM_n2 is zero and PWM_n1 is 1 (or whatever value the C18 compiler uses for “true”) or if PWM_n2 is non-zero and PWM_n1 is zero.

If the remote is off, or there is no receiver plugged into the EDU RC, all PWM in values will be 127.

If you are getting all 127s, you can’t really tell if there is no PWM input, or if your remote is on but everything is perfectly centered. But perhaps you could trim your remote slightly off center, but still within the deadband (128 or 129, for example) and program your RC so that it knows that perfect 127s represent transmitter off, but that anything else represents transmitter on.

on the other hand, the chances that all of the PWMs will be dead-centered is fairly slim, so if every single one is reading as 127, you could probably assume the controller isn’t plugged in/on.

If the controller is cheap (low res: 3 posible values per stick). Of course, if your paying $130, probably not.