Not sure on programming.n

I tried setting my motors but unable to make my bot move. I can only operate the arm going up and down. WHen I use the tank control nothing moves.
I do have an intake and shooter on separate motors, but not sure how to let the brain know what is what.I have six motor altogether and I have set the
motors to whatever port it’s plugged into. stressing :frowning:

In the device setup, you need to assign the drivetrain motors to either left or right side. The other motors are set to none.
The built-in functions like forward() and tankControls use this configuration to know which motors to spin up for the left side and for the right side.

Thank you. I just did that and now it can move forward and backwards, but how do I get the intake and shooter to function?
When I program do I set the motors for intake and shooter?

On the approach, you can try something like this (or close to that, it should be doable even in graphical…):


task main() {
    while(true) {
        if (getJoystickValue(BtnEUp) == 1) {
            moveMotor(armMotor, 850, degrees, 100);
        } else if (getJoystickValue(BtnEDown) == 1) {
            moveMotor(armMotor, -850, degrees, 100);
        }
        if (getJoystickValue(BtnFUp) == 1) {
            moveMotor(clawMotor, -270, degrees, 100);
        } else if (getJoystickValue(BtnFDown) == 1) {
            moveMotor(clawMotor, 270, degrees, 100);
        }
        tankControl(ChA, ChC, 50);
    }
}

Remember, tankControl is a non-blocking function. It just evaluates the state of the joysticks and update the motor speeds accordingly, so you can do the same in your code.
The above is very simplified and actually uses blocking calls in reaction to the buttons. You’d better replace that with setMotor() or stopMotor() as needed.

Thank you for the information…not sure what you mean with… The above is very simplified and actually uses blocking calls in reaction to the buttons. You’d better replace that with setMotor() or stopMotor() as needed.

Do I use the above code in graphical?

Sorry, I’m new to programming so confused at what I’m doing. The above program looks like Robot C language not in graphical?

The above code tells the motors to move for a specific distance and does not allow you to do anything else at the same time. It blocks other functions.

Here (attached picture) is a sample to control the motors. They will run as long as you press the buttons, and stop when you release them all.

Steve

So do I still keep the tank control and what I set up for the scoop in the same loop?

Also, after you download the program, do you always need to turn off the brain, then turn it on again to go to your program?

thank you very much for your help.:o

This would ONLY control one motor. You may want to add another motor, and the tank control.

You should not need to turn the brain off each download.

Steve

Hi
I added the tank control and the arm control inside the loop above the if/else statement, but now the shooter doesn’t work with the buttons, when I move the joystick the shooter moves. Also, my whole bot doesn’t move.

Thank you thank you…with some playing around. Everything is working correctly.:slight_smile:

Half of programming is playing around. Have fun.

Well, maybe I spoke to soon. The robot moves, the arm lifts, however the shooter does not respond. Only when I’m driving it and press the buttons L/R it starts to move.
I used what you suggested. Added the arm control at the top inside the loop and added tank controls too.

Okay, I found out what was going on. Needed to put my wires into the right ports, for the tank mode. I forgot I had switched them for some reason.