|
Your code looks about right. You may have a hardware problem.
Are you using a joystick or a switch wired in to the p1_sw_top pin on port 1? Using the joystick, you should get 0 when the button is not depressed and 1 when it is. It's easy enough to throw in a debug to verify that.
If you are using a switch wired in to the port make sure that you are wired to the normally open side of the switch. If the switch has three tabs on it, usually one will have NO and another will have NC next to them. NO is normally open, NC is normally closed. The third tab wil go to ground.
Once again, debug statements are the way to go. I always check out the code operation without any PWMs or relays plugged in to the Robot Controller and use debug statements to verify operation. This tip comes from a bitter experience as the team rookie coder when I loaded up my first ever piece of code and promptly destroyed our lifting mechanism. Ouch, that hurt.
I hope this helps.
__________________
Warren B
Pool Noodles. They're not just for bumpers anymore.
|