Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void getNumber(){
- scratch = ""; // clear scratch for a new scan
- /* Data takes form:
- *
- * +---------+----+----+----+----+----+----+----+----+----+-----+----+----+---------+---------+---------+
- * | 2 (STX) | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9 | D10 | C1 | C2 | 13 (CR) | 10 (LF) | 3 (ETX) |
- * +---------+----+----+----+----+----+----+----+----+----+-----+----+----+---------+---------+---------+
- *
- */
- char c = Serial.read(); // get the first character
- while (c != 2){c = Serial.read();} // if its not STX, keep going till it is
- // (though this is bad!)
- if (c == 2){ // now that we have STX
- while ( c != 3 ){ // loop through all new date till we get ETX
- c = Serial.read();
- scratch += c; // and append it to scratch
- }
- }
- scratch = scratch.replace(13, '\0'); // clean away
- scratch = scratch.replace(10, '\0');
- scratch = scratch.toLowerCase();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement