Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. void setup() {
  2. // initialize the digital pins as an output.
  3. pinMode(13, OUTPUT);
  4. // Turn the Serial Protocol ON
  5. Serial.begin(9600);
  6. }
  7.  
  8. void loop() {
  9. byte byteRead;
  10.  
  11. if (Serial.available()) {
  12.  
  13. /* read the most recent byte */
  14. byteRead = Serial.read();
  15. //You have to subtract '0' from the read Byte to convert from text to a number.
  16. byteRead = byteRead - '0';
  17. Serial.print(F("byteRead = "));
  18. Serial.println(byteRead);
  19.  
  20. int i,j;
  21. for ( i = 0; i < byteRead; i++) {
  22. for ( j = 0; j < 3; j++) {
  23. if (Serial.available()) {
  24.  
  25. /* read the most recent byte */
  26. byteRead = Serial.read();
  27. //You have to subtract '0' from the read Byte to convert from text to a number.
  28. byteRead = byteRead - '0';
  29. Serial.print(i);
  30. Serial.print(':');
  31. Serial.print(j);
  32. Serial.print(F(":byteRead = "));
  33. Serial.println(byteRead);
  34. }
  35. }
  36. }
  37. }
  38. }
  39.  
  40. for ( i = 0; i < byteRead; i++) {
  41. ...
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement