Advertisement
obernardovieira

[Arduino] Get the right text from serial

Sep 15th, 2016
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. void setup()
  2. {
  3.     Serial.begin(9600);
  4. }
  5.  
  6. void loop()
  7. {
  8.     if(Serial.available() > 0)
  9.     {
  10.         char input[16];
  11.         byte len = Serial.available();
  12.         Serial.readBytes(input, 16);
  13.         input[len] = '\0';
  14.         Serial.println(input);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement