Advertisement
gabbyshimoni

exampleArray

May 21st, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. char code[5] = {'2', '0', '6', '1', '8'};
  2. char getCode[5];
  3. int isCorrect = 0;
  4. void setup() {
  5.   Serial.begin(9600);
  6.   for (int i = 0; i < 5; i++) {
  7.     while (Serial.available() == 0);
  8.     getCode[i] = Serial.read();
  9.     if (getCode[i] == code[i]) {
  10.       isCorrect++;
  11.     }
  12.   }
  13.   if (isCorrect == 5 ) {
  14.     Serial.println("Welcome");
  15.   }
  16.   else {
  17.     Serial.println("Wrong code, try again");
  18.   }
  19. }
  20.  
  21. void loop() {
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement