well, the entire code is here:
/*
Serial Event example
When new serial data arrives, this sketch adds it to a String.
When a newline is received, the loop prints the string and
clears it.
A good test for this is to try it with a GPS receiver
that sends out NMEA 0183 sentences.
Created 9 May 2011
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/SerialEvent
*/
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
void setup() {
// initialize serial:
Serial.begin(9600);
}
void loop() {
/*
if (Serial.available()) {
Serial.print((char)Serial.read());
}
*/
// print the string when a newline arrives:
if (stringComplete) {
Serial.println(inputString);
// clear the string:
inputString = "";
stringComplete = false;
}
}
/*
SerialEvent occurs whenever a new data comes in the
hardware serial RX. This routine is run between each
time loop() runs, so using delay inside loop can delay
response. Multiple bytes of data may be available.
*/
void serialEvent() {
Serial.println("wtf?");
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.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;
}
}
}
taken and modified a little bit from the tutorial.
as it is, serialEvent is never called, but if i uncomment the first lines of loop(), those:
if (Serial.available()) {
Serial.print((char)Serial.read());
}
It prints me back successfully all that i send.
Tryed even sending some '\n' (the real char ofc), CR, ecc. but nothing.
I'll try the code of buteman and let u know ![]()
Tnx for the moment for your answers =)