Well they are both accurate. The tutorial is referring to which bit to mask. The program is referring to which bit value to mask. Bit 3 has a value of 8.
Bit = 0, 1, 2, 3
Value = 1, 2, 4, 8
No countradiction in operation, just in the numbering system used. They were done by different people.
I think technically Nathan used the wrong terminology. I will correct the program and put it on the website.
it is probably just my beginner programming skills, but i still can’t get the L1 and L2 buttons to work, all that happens is the servo that is on pin 15 goes all the way to the stop point
temp=button2 & 8 ' Filter out all but bit 3, R2.
if temp=0 then ' If button is pressed then do the following.
servo4 = servo4 - 25 ' Open the gripper.
if servo4 < 750 then ' Hold the value to 750 minimum.
servo4 = 750
endif
endif
temp=button2 & 2 ' Filter out all but bit 1, R1.
if temp=0 then ' If button is pressed then do the following.
servo4 = servo4 + 25 ' Close the gripper.
if servo4 > 2250 then ' Hold the value to 2250 maximum.
servo4 = 2250
endif
endif
can i juse copy this part of the code and paste it, replace the mask bit for L1 and L2 and activate the pin 15 pulseout and all those other things? cause i tried that and it doesn’t work
temp=button2 & 8 ' Filter out all but bit 3, R2.
if temp=0 then ' If button is pressed then do the following.
servo5 = 3000 - servo4 ' Open the gripper.
if servo5 < 750 then ' Hold the value to 750 minimum.
servo5 = 3000 - servo4
endif
endif
temp=button2 & 2 ' Filter out all but bit 1, R1.
if temp=0 then ' If button is pressed then do the following.
servo5 = 3000 - servo4 ' Close the gripper.
if servo4 > 2250 then ' Hold the value to 2250 maximum.
servo5 = 3000 - servo4
endif
endif
temp=button2 & 8 ' Filter out all but bit 3, R2.
if temp=0 then ' If button is pressed then do the following.
servo4 = servo4 - 25 ' Open the gripper.
if servo4 < 750 then ' Hold the value to 750 minimum.
servo4 = 750
endif
endif
temp=button2 & 2 ' Filter out all but bit 1, R1.
if temp=0 then ' If button is pressed then do the following.
servo4 = servo4 + 25 ' Close the gripper.
if servo4 > 2250 then ' Hold the value to 2250 maximum.
servo4 = 2250
endif
endif
servo5 = 3000-servo4
yup!
The big if…then bit is about using the state of the buttons to increment or decrement on running position value for servo4.
We aren’t trying to do anything except for make a copy of whatever that value is, and invert it. So we let servo4 and its control logic behave just as before, then invert it over into servo5.
i had been tinkering with the bits that Jim had given me and thats wat the problem was the whole time, the bits were just wrong, thanks so much for everyones help, ecspecially urs andy, u didn’t give up on me
'L. Scoop up/down
temp=button2 & 1 ' Filter out all but bit 0, L2.
if temp=0 then ' If button is pressed then do the following.
servo5 = servo5 - 25 ' Open the gripper.
if servo5 < 750 then ' Hold the value to 750 minimum.
servo5 = 750
endif
endif
temp=button2 & 4 ' Filter out all but bit 2, L1.
if temp=0 then ' If button is pressed then do the following.
servo5 = servo5 + 25 ' Close the gripper.
if servo5 > 2250 then ' Hold the value to 2250 maximum.
servo5 = 2250
endif
endif
If you do the if…then block and maintain running tallys for servo4 and servo5 independently, then you will need to make sure they are initialized to inverted values.
Things will be simpler if you do as I suggested, calculate servo4 just as it was done originally, then set servo5 based upon the results.