Advertisement
Guest User

readSerial.h

a guest
Nov 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. bool startCharFound = false;
  2. int incomingByte = 0;
  3.  
  4. String message;
  5.  
  6. void readSerial(){
  7.   if (Serial.available() > 0) {
  8.       incomingByte = Serial.read();
  9.  
  10.       char receivedCharacter = (char) incomingByte;
  11.  
  12.       if(receivedCharacter == '%'){
  13.         startCharFound = false;
  14.       }
  15.  
  16.       if(startCharFound == true){
  17.         message += receivedCharacter;
  18.       }
  19.  
  20.       if(receivedCharacter == '#'){
  21.         startCharFound = true;
  22.         message = "";
  23.       }
  24.   }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement