Advertisement
ShamelessName

Arduino SerialComms

Feb 1st, 2014
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. boolean msgGot=false;
  2. char confChar=7;
  3.  
  4. void setup()
  5. {
  6.   Serial.begin(38400);
  7. }
  8.  
  9. void loop()
  10. {
  11.   establishConnection();
  12. }
  13.  
  14.   void establishConnection()
  15.   {
  16.     delay(345);
  17.     while(msgGot==false)
  18.     {
  19.       Serial.println(confChar);
  20.     }
  21.     for(Serial.available()<=0; msgGot=false;)
  22.     {
  23.       if(Serial.read()==confChar)
  24.       {
  25.         msgGot=true;
  26.         Serial.println("Connection established!");
  27.       }
  28.     }
  29.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement