while(true) {
if(joystickGetDigital(1,5,JOY_UP)) { // choose the appropriate button on the appropriate controller
if(!buttonHeld) { // only do this swap if this is a new button press
buttonHeld = true; // remember that the button is held down so we have to wait for a release
motorOn = !motorOn; // toggle the state for the motor
if(motorOn) { // if the motor should now be on, turn in on
motorSet(1,100); // choose the appropriate port and speed
}
else { // if the motor should now be off, turn in off
motorSet(1,0); // choose the appropriate port
}
}
}
else {
buttonHeld = false; // the button is not being held down, so the next time it is detected is a new press
}
delay(10);
}
}
This is the code what I wrote in order to control the robot by pressing buttons. However, this program is not being downloaded into the brain. What might be the problem?
It looks like you’re jus trying to run the code instead of making it and uploading it to the robot. How have you set up Atom or whatever you’re using as an editor for PROS and what are you doing to try to use the program? For example, in the lower-left we set it to make-upload, if I remember correctly, and then we ran make-upload (usually by keystroke, which I want to say was command-shift-9 on a Mac, but it’s been a while).
Hi, so the lower left button just opens a terminal. We are pressing the upload button (as shown in the picture… attached as a file below) when uploading the program (in the picture the program is not visible but it is just to illustrate that we are pressing the upload button in the top left corner)
Hm… Mine looked a little different. But you should be able to choose make-upload as your ^F9 option instead of just upload. Then you can do ^F9 and it will make the project and then upload it after making it.
@TitanRey15 there’s a couple ways you can build the project. The most straightforward way is to navigate to the PROS menu (should be in the menu bar, possibly under the “packages” entry), and click “Build Project.” By default, this command is bound to ctrl-f9 (and it’s possible we didn’t think to add a separate binding for macOS). Another way to do it is to hit cmd+shift+p to open the command palette and type “PROS:Make-Project” and hit enter.