hi all,
i am trying to communicate a serial device (pic 12f) with arduino mega.
i connected device to serialport3. when i send command 'g' to serialport3, device blinks a led and sends a sentence like "ok now\n\r".
i send 'g' command to the device by sending 'a' command to arduino. also i want to see the device's reply from arduino serial monitor.
i see the led blinks but i couldn't read the sentence.
i am trying to modify serial event skecth, where problem can be?
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
inputString.reserve(200);
void setup() {
Serial.begin(9600);
Serial3.begin(9600);
// reserve 200 bytes for the inputString:
inputString.reserve(200);
}
void loop() {
/*
if (Serial.available())
{
char ser = Serial.read();
if(ser == 'a'){
Serial3.write('g');
}
}
}
*/
if (stringComplete) {
Serial.println(inputString);
// clear the string:
inputString = "";
stringComplete = false;
}
}
void serialEvent() {
while (Serial3.available()) {
// get the new byte:
char inChar = (char)Serial3.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '\n') {
stringComplete = true;
}
}
}