UART equivalent to Serial.parseInt() ?

Status
Not open for further replies.
Hi!
I am working with this sketch right now on Teensy 2.0 which works very fine:

http://arduino.cc/en/Tutorial/ReadASCIIString

BUT now I don't want to receive data via USB BUT via the UART (Pin 7 & 8)!
How can this be managed?

Of course I tried to replace "Serial" with "Uart" which I think is working with Serial<->Uart.available.

But it seems that

Code:
int red = Uart.parseInt();

Is not working while Arduino is compiling that.

Any Idea? First reading the data as a complete string and than using stream.parseInt() ?

Thanks in advance,

Roland
 
Try Serial3.parseInt()

If that doesn't fix it, please describe how you're testing and post the exact code you're running, and I'll give it a try here. Please be specific enough so I can exactly recreate the situation. I can usually solve reproducible problems, but if I can't recreate it here, there's not much I can do.
 
Thanks for your Help!

Try Serial3.parseInt()

This is not known by Arduino (I am using a Teensy 2.0 Board).

I now fixed the bug on my own, this code is working now:

Code:
HardwareSerial Uart = HardwareSerial();

void setup() {
  Serial.begin(9600);
  Uart.begin(9600);
 }

void loop() {
  while(Uart.available() > 0) {
    
    int red = Uart.parseInt(); 
    int green = Uart.parseInt();
    int blue = Uart.parseInt(); 

    if (Uart.read() == 13) {  //THIS is the improvement (Uart.read() == '\n') IS NOT working 

      Serial.print(red, DEC);
      Serial.print(green, DEC);
      Serial.println(blue, DEC);
    }
  }
}

This is the string I am sending via Uart (Ascii: 145,60,11\n)

49
52
53
44
54
48
44
49
49
13

The Data is transmitted back via Serial without problems!



Thank you

Roland
 
Status
Not open for further replies.
Back
Top