daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int count = 0;                                    // count = 0
  2. char userInput[5];
  3.  
  4. void setup()
  5. {
  6.   delay(1000);
  7.   Serial.begin(19200);                            // begin serial port with baud rate 9600bps
  8.  
  9. }
  10. void loop()
  11. {
  12.   if (Serial.available() > 5)
  13.   {
  14.     Serial.read();
  15.   }
  16.  
  17.   else if (Serial.available() < 4)
  18.   {
  19.     Serial.read();
  20.   }
  21.  
  22.   else if (Serial.available() == 5)
  23.   {
  24.     for (int i = 0; i < 5; i++)
  25.     {
  26.       userInput[i] = Serial.read();
  27.     }
  28.  
  29.     Serial.print("User Input - ");
  30.     Serial.println(userInput);
  31.   }
  32.  
  33.   delayMicroseconds(10000);
  34. }
  35.    
  36. abcde
  37. abcd
  38. abcd
  39. abcd
  40. abcd
  41. abcdef
  42. abcde
  43.    
  44. User Input - abcde
  45. User Input - dabcd
  46. User Input - dacbd
  47. User Input - bcdef
  48. User Input - abcde
RAW Paste Data
Top