Macros in Block Code

Hey Everyone,
I am trying to code Macros for Doinker and our LadyBrown Mechanism. Whenever I press down the doinker goes down, but when I press up, nothing happens. Neither for Wallstake Mechanism.


1 Like

Have you defined what the Doinker positions are? The question also extends to the Ladybrown. If you haven’t, then I recommend it, as it has no idea what the positions are.

Maybe it’s because you’re using two forever loops? I know that blocks isn’t great at doing things parallel so they could be conflicting with each other

That could be it, maybe the code just needs to be in 1 forever loop.

1 Like

So put it all in one forever loop under when started or driver control

Since I put the integer value, should that define it?

Under driver control, since that’s when you control the robot. But you can experiment of course

You need to make a variable that says “Doinker Position 1 = x degrees.” Fill in the x, and input that.

1 Like

This si the current code. Currently, Everything works until I make the doinker go down. After that, the LadyBrown decides not to move anymore. Everything else still works, except the LadyBrown Mechanism.


The doinker also does not go back up after I make it go down.

This might be an easier version. I think you want your lady brown to cycle through positions each time you press a button, and the doinker to move to up and down to fixed positions depending on the button pressed.

This code uses events instead of forever loops, and it will run each event in a different thread so they won’t fight each other. The events will only fire once on each button press so you won’t have the toggle issues that you would with a loop.

I don’t have the robot currently, so I am pseudo coding. I have a question though. For spin the LBrown to each item on the list, wouldn’t you want to do that after you add 1 to the wall position? That way it would change the current wall position and then go to the corresponding angle.

That works too. You need to determine what action to take for your starting move. Is it the first value in the list or second?

You could also put the motor move in a separate function, call it from a cycle button (IE: ‘X’), and also have dedicated event buttons that move it to a specific position (if necessary).

Could it be a physical problem? Other than that, you could try to use the “when controller1 [button] pressed” event block instead of having if statements.

I fixed it using that code. I think using the event block statements made it less confused and conflicting than the if statements. Everything works and thanks for all the help!

1 Like