RuiViana

Laser.ino

Mar 28th, 2021 (edited)
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2. SoftwareSerial mySerial(2, 3); // RX, TX
  3.  
  4. byte variable[7];
  5. int index = 0;
  6. bool printResult = false;
  7. //----------------------------------------------------------------
  8. void setup()
  9. {
  10.   Serial.begin(200);    
  11.   mySerial.begin(200);
  12. }
  13. //----------------------------------------------------------------
  14. void loop()
  15. {
  16.   while (mySerial.available() > 0)
  17.   {
  18.     byte b = mySerial.read();
  19.     variable[index++] = b;
  20.     printResult = true;
  21.   }
  22.   if (printResult == true)
  23.   {
  24.     Serial.print("variable 0: "); Serial.println(variable[0], HEX);
  25.     Serial.print("variable 1: "); Serial.println(variable[1], HEX);
  26.     Serial.print("variable 2: "); Serial.println(variable[2], HEX);
  27.     Serial.print("variable 3 temperatura: "); Serial.println(variable[3], DEC);
  28.     Serial.print("variable 4: "); Serial.println(variable[4], HEX);
  29.     Serial.print("variable 5: "); Serial.println(variable[5], HEX);
  30.     Serial.print("variable 6: "); Serial.println(variable[6], HEX);
  31.     index = 0;
  32.     printResult = false;
  33.   }
  34. }
Add Comment
Please, Sign In to add comment