The area where it has 01, 02 and 03 SHOULD be where you put the number of the button you would like to use, according to the help files. For some reason whenever I attempt to use the code, only button 1 works, and it trys to run every one of these commands at once and starts freaking out.

I have been tearing my hair out over this for a while and any help would be appreciated.

Tue Dec 09, 2008 7:40 pm

tfriez

Site Admin

Joined: Wed Jan 24, 2007 10:42 amPosts: 620

Re: "if (joy1btn(btn) !=0)" Help?

Please search the forums to see if your question has been answered before posting a new thread.

The area where it has 01, 02 and 03 SHOULD be where you put the number of the button you would like to use, according to the help files. For some reason whenever I attempt to use the code, only button 1 works, and it trys to run every one of these commands at once and starts freaking out.

I have been tearing my hair out over this for a while and any help would be appreciated.

I have had some weird things happen when I enter code one way, when you can enter it another. If this does, fix it, then it means that your RobotC was just acting up. If this does not fix it, then can you post your entire code? There may be another problem that is existing within another part of your code, and without knowing what the rest of it is, i cannot know for sure.

adding the ==1 isn't going to help, and in fact I think it will work even less well, since in addition to the operator precedence problem discussed at significant length in the referenced thread, you are going to be doing something likeif (x & 1 << 3 ==1 )and even on a good day, it won't equal 1. i.e. even if things are properly parenthesized:if ((x & (1 << 3)) ==1 )it isn't going to ==1. if the button is pressed, (x & (1 << 3)) is going to be 8, not 1. (this would be an example for button 4)

Management summary:1. Follow tfriez advice and don't say == anything when using the joy2btn(b) macro.2. Understand my explanation of the operator precedence issues that make the #define not work when used with ==.

Extra credit:3. write your own MyJoy2Btn(b) macro that tolerates the use of ==

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum