Rover 1 w/ scoop

o yea, that substance im picking up is dog food :laughing:

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.

o0o0o, i see :open_mouth:

do you have the mask bit for the PS2 L1 and L2 buttons? and if you do, do you think you could give them to me? im very fuzzy on all of this

The corrected file is uploadedā€¦
L1 is bit 2 and L2 is bit 0.

thanks so much Jim, ill let u know how it turns out

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

Chunga, What micro are you using? the BS2 or the Atom?

oopsā€¦ I made an errorā€¦ I didnā€™t take into account the low-side offset of 750.

To properly invert servo4 to servo5

servo5 = 3000-servo4

im using the ATOM

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

so is this is wat it should look like andy?

nopeā€¦

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

thats it? i just plug

servo5 = 3000-servo4 in where i want the code to be?

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.

thatā€™s it. :slight_smile:

SUCCESS!!! :smiley: :smiley: :smiley:

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 :laughing:

heres the code that was such much trouble

'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

last comment:

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.

yea, im sure it would be, but im not sure i could figure it out :laughing:

I gave you the codeā€¦ starting from what you originally posted, uncomment the one line and just before it add the:

servo5 = 3000-servo4

thatā€™s it.

well, sound simple enough but i still dont know where that one line is :blush: