I am having difficulty with the software serial port. I have spent nearly a full day on this issue, so I feel it is now time to go to the community for help.
I am attempting to use an Arduino Uno to talk with the Sabertooth 2x32 motor controller. I want to be able to use the hardware serial so I can use the Serial Monitor , so I am using the Software Serial ports to talk with the Sabertooth..
I have successfully created a simple program that sends commands to the Sabertooth over the Software Serial.
Now I am attempting to query the motor amperage and then forward the text response from the Sabertooth to the hardware serial. This way I can read it in the Arduino's serial monitor on my Windows machine.
Here is the code, with the line that generates the error highlighted.
#include <SoftwareSerial.h> //Load the sofware serial library
SoftwareSerial SaberSoftSerial(11, 9); //Define software serial
void setup() {
SaberSoftSerial.begin(9600); //set baud rate for software serial
serial.begin(57600); //start the hardware serial port
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
serial.println("just testing"); // <<<<<<<<<<<<< IT IS OK WITH THIS LINE
}
void loop() {
SaberSoftSerial.println("M1:1000"); // Send a command out Software Serial to Sabertooth.
delay(1000);
SaberSoftSerial.println("A1:get"); // Request amperage on motor 1 via software serial.
// read the text that the Sabertooth motor controller sends, and forward it to hardware serial.
if (SaberSoftSerial.available()) {
serial.print(SaberSoftSerial.read); // THIS LINE GENERATES ERROR, SAYING 'serial' was not declared in this scope.
serial.println(" amps");
}
}
I believe my hardware serial port is already setup and has those related commands in the proper ares of the program. So, why am I getting the "Not defined in this scope" message? Is there some sort of conflict with the hardware serial?