daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Dec 15th, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <Wire.h>
  3. #include <LiquidCrystal_I2C.h>
  4.  
  5. char locked[]="Locked";
  6. char locked1[]="Locked  *";
  7. char locked2[]="Locked  **";
  8. char locked3[]="Locked  ***";
  9. char locked4[]="UNLOCKED";
  10.  
  11. char unlocked[]="Unlocked";
  12. LiquidCrystal_I2C lcd(0x27,16,2);
  13. int hallSensor1 = 8;
  14. int hallSensor2 = 9;
  15. int hallSensor3 = 10;
  16. int hallSensor4 = 11;
  17. int hallState1 = 0;
  18. int hallState2 = 0;
  19. int hallState3 = 0;
  20. int hallState4 = 0;
  21. int total = 0;
  22. int laser = 12;
  23.  
  24. void setup()
  25. {
  26.   lcd.init();
  27.   lcd.backlight();
  28.   pinMode(hallSensor1, INPUT);
  29.   pinMode(hallSensor2, INPUT);
  30.   pinMode(laser, OUTPUT);
  31. }
  32.  
  33. void loop()
  34. {
  35.  
  36.   hallState1 = digitalRead(hallSensor1);
  37.   hallState2 = digitalRead(hallSensor2);
  38.   hallState3 = digitalRead(hallSensor3);
  39.   hallState4 = digitalRead(hallSensor4);
  40.   total = 0;
  41.  
  42.   if (hallState1 == LOW) {
  43.     total += 1;
  44.   }
  45.   if (hallState2 == LOW) {
  46.     total += 1;
  47.   }
  48.    if (hallState3 == LOW) {
  49.     total += 1;
  50.   }
  51.    if (hallState4 == LOW) {
  52.     total += 1;
  53.   }
  54.   switch (total){
  55.   case 0:
  56.     lcd.clear();
  57.     lcd.setCursor(0,0);
  58.     lcd.print(locked);
  59.     delay(50);
  60.   break;
  61.  
  62.   case 1:
  63.     lcd.clear();
  64.     lcd.setCursor(0,0);
  65.     lcd.print(locked1);
  66.     delay(50);
  67.    break;
  68.    
  69.    case 2:
  70.     lcd.clear();
  71.     lcd.setCursor(0,0);
  72.     lcd.print(locked2);
  73.     delay(50);
  74.    break;
  75.  
  76.    case 3:
  77.     lcd.clear();
  78.     lcd.setCursor(0,0);
  79.     lcd.print(locked3);
  80.     delay(50);
  81.    break;
  82.  
  83.    case 4:
  84.     lcd.clear();
  85.     lcd.setCursor(0,0);
  86.     lcd.print(locked4);
  87.     delay(50);
  88.    break;
  89.   }
  90.  
  91. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top