Code error?

Alright our team has been trying to run a motor through a pwm with the buttons on the joystick.

if (p1_sw_aux1 = 1 && p1_sw_aux2 = 0)
	{
		pwm10 = 255
	}
else if (p1_sw_aux1 = 0 && p1_sw_aux2 = 1)
	{
		pwm10 = 0
	}
else
	{
		pwm10 = 127
	}

This returned nothing on the motor and we are positive the motor runs.
We also tried just using pwm10 = 255 to see if anything would happen and we got absolutely nothing in return. The motor just constantly sits there, we think its an electrical problem but we are still getting told its a programming error. If this is true can anyone tell us what it is we are doing wrong?

in the if then, you have to use two = signs (like this ==)

We have tried that as well and it returned nothing. (I am not at our coding laptop and do not have a copy of the code with me so I am throwing the code out from memory.)

when you turn the robot on, what do the victor lights do? if they are blinking orange, then you should check the pwm wires to make sure they’re fully in

just to clarify, that means u just put pwm10 = 255 without any if-then statements right?

did you copy paste the code from the actual code? or did you just type it up as an example. because you are missing semi-colons at the ends of your lines, too.

I believe it may be the victors, i remember seeing orange lights but the electric team said it was normal. Yes, i meant without any if statements, and i just threw it out from memory. I never can remember those semi colons XD

take a look at the third page. it describes what the lights mean and how to troubleshoot the victor

Step back from the immediate problem a bit and make sure the larger environment is okay. Are you certain you’re downloading the newly created .hex file? Are you even certain you’re successfully compiling the program in the first place? In addition to the incorrect equality test, the code you posted has some missing semicolons that I would have expected to cause syntax errors.

We had been messing with the pwm cords prior to the testing, as we didn’t know for sure which way they were supposed to go in. We may not have put it in fully.

Thank you

Yea, make sure the black side of the pwm is lined up with the B on the victor, and that the pwm’s are in firmly. good luck!

Sorry to ask the obvious question but,
pwm10? Are you sure you did not mean pwm01?

Try putting in a printf and then let the loader open the terminal window after programming. Leave the programming cable on. (Its a good idea to put blocks under any drive wheels while running with a computer connected to the robot)
Add this line
printf(“p1_sw_aux1 = %d, p1_sw_aux2 =%d\r”, p1_sw_aux1, p1_sw_aux2);

What buttons are you pressing? The trigger is p1_sw_trig, and the thumb switch is p1_sw_top, I don’t think the aux inputs are connected to anything on the joystick.

As for setting the motor to 255, every time in the loop it should always go.

Brian

Yes i mean pwm10 thats the pwm we are using, and we have tested the aux buttons they are attached to buttons on the top of our joystick. Today we went back and looked and found that we hade a bad victor, we are getting that fixed now. Thank you to all who helped.