01-02-2019, 03:52 PM
Several notes about the previous post/script.
A) I have a "debug" flag that is used to send output to the computer via USB if the computer is monitoring it. That prints messages so you can see if the R/C signals are being read correctly, etc.
If you don't want that, you can change it to
B) As part of "debug mode" there's a statement that makes the motors cycle a little so you can check if they're moving the right directions. You may comment that out with // to disable the test sequence, or remove the comment (and change the debug flag to true) to do the test motor sequence.
This test sequence moves the motors when the script starts so you can see that it's correctly talking to the motors and moving them in the correct directions.
This (along with "bool debug = true;" above) runs the motor test sequence:
To disable the motor test sequence, either set "bool debug = false;" above, or "comment out" this line as below. (// lines are treated as comments and ignored by the compiler)
C) Some Arduinos have only a single "Serial" port (which is shared with the USB communication), and some have multiple "Serial" ports. The script was originally written for a Leonardo, which has a "Serial1" port.
If your Arduino doesn't have a "Serial1" port, change ALL of the "Serial1" references to "Serial" in the script. Note that when you do that you can't use the USB port to talk to the computer, so make sure you set the "bool debug = false;" above so that the script won't try to send USB data to your motors!
Of course if your Arduino has more than 2 Serial ports you could also change the Serial1 to Serial2 or Serial3 if that's better for your application.
A) I have a "debug" flag that is used to send output to the computer via USB if the computer is monitoring it. That prints messages so you can see if the R/C signals are being read correctly, etc.
Code:
// Toggle spewing of debug spew
bool debug = true;
If you don't want that, you can change it to
Code:
// Toggle spewing of debug spew
bool debug = false;
B) As part of "debug mode" there's a statement that makes the motors cycle a little so you can check if they're moving the right directions. You may comment that out with // to disable the test sequence, or remove the comment (and change the debug flag to true) to do the test motor sequence.
This test sequence moves the motors when the script starts so you can see that it's correctly talking to the motors and moving them in the correct directions.
This (along with "bool debug = true;" above) runs the motor test sequence:
Code:
// Quick test program
// THIS MAKES THE MOTORS MOVE, COMMENT OUT TO NOT DO THIS!!!
testMotors();
To disable the motor test sequence, either set "bool debug = false;" above, or "comment out" this line as below. (// lines are treated as comments and ignored by the compiler)
Code:
// Quick test program
// THIS MAKES THE MOTORS MOVE, COMMENT OUT TO NOT DO THIS!!!
// testMotors(); // Commented out with //
C) Some Arduinos have only a single "Serial" port (which is shared with the USB communication), and some have multiple "Serial" ports. The script was originally written for a Leonardo, which has a "Serial1" port.
If your Arduino doesn't have a "Serial1" port, change ALL of the "Serial1" references to "Serial" in the script. Note that when you do that you can't use the USB port to talk to the computer, so make sure you set the "bool debug = false;" above so that the script won't try to send USB data to your motors!
Of course if your Arduino has more than 2 Serial ports you could also change the Serial1 to Serial2 or Serial3 if that's better for your application.