I am not sure if there is a more appropriate place to post his so my apologies in advance if this is not the correct place...
I am using a Teensy board which is an arduino variant and has the capability to communicate with a PC's USB COM port
once a sketch is running but I am having some problems sending commands to it from my PC.
On the Teensy board and using the Arduino IDE, there is a set up in the tools drop down for the COM port serial monitor which
I am using to view the serial data.
Here is my code:
int Red = 0; // control pin for the Red LED
int Green = 1; // control pin for the Green LED
int cmd; // input command from PC
void setup() {
pinMode(Red, OUTPUT); // Set Red LED pin as an output pin
pinMode(Green, OUTPUT); // Set Green LED pin as an output pin
Serial.begin(9600);
}
void loop() {
// wait for serial input
if (Serial.available() > 0) { // read the incoming byte:
cmd = Serial.read(); //Serial.println("cmd read ="); `
Serial.print(cmd);
Serial.println(""); // prints another carriage return
// ASCII '<' is 44, ASCII '>' is 46 (comma and period, really)
if (cmd == 114) { digitalWrite(Red, HIGH); } // turn on red led.
if (cmd == 115) { digitalWrite(Red, LOW); } // turn off red led
if (cmd == 103) { digitalWrite(Green, HIGH); } // turn on green led
if (cmd == 104) { digitalWrite(Green, LOW); } // turn off green led
}
}
I can send an r, s, g, or h from the COM 3 Serial monitor which sets my leds on and off as they should per the code
but the next step is to get the PC to communicate these characters to it...
I made a winbatch script that I am using to send these characters out to the Com port 3 and I have these logged in a log file and they
appear to be sent to the serial port without a problem but the teensy board is not seeing these
nor is the Com3 serial monitor.
Why can't the arduino pick up on this data sent to it with the winbatch script?
Is there any other way to test this such as sending a character to the com port from the command line prompt?
thanks in advance for any useful ideas in figuring this thing out...