Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. #include <Servo.h>// includes the servo moteur library
  2. Servo myservo;
  3. int y=0;
  4. #include <Wire.h>
  5. #include <LiquidCrystal_I2C.h> // includes the LiquidCrystal Library
  6. LiquidCrystal_I2C lcd(0x27, 2, 1 , 0, 4, 5, 6, 7, 3, POSITIVE); //
  7. Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
  8. const int place[]={13,12,11,10,9,8};
  9. byte val[6];
  10. const int in =7;
  11. const int out =6;
  12. int count=0;
  13. int valin=0;
  14. int valout=0;
  15. int pos=51;
  16. int cnt;
  17.  
  18.  
  19.  
  20.  
  21.  
  22. void setup() {
  23.  
  24. Serial.begin(9600);
  25. for (int i=0;i<5;i++)
  26. {pinMode(place[i],INPUT);}
  27.  
  28. pinMode(in,INPUT);
  29. pinMode(out,INPUT);
  30.  
  31. myservo.attach(5);
  32.  
  33. lcd.begin(16 , 2);
  34.  
  35. lcd.setCursor(0, 0);
  36. lcd.print("systeme allumer");
  37.  
  38. myservo.write(0);
  39. for (pos=51 ; pos>=0; pos--){
  40. myservo.write(pos);
  41. delay(30);
  42. }
  43. delay(1000);
  44. for (pos=0; pos<=51; pos++){
  45. myservo.write(pos);
  46. delay(30);
  47. }
  48. lcd.clear();
  49. lcd.setCursor(0, 0);
  50. count=0;
  51. }
  52.  
  53.  
  54. void loop() {
  55.  
  56. lcd.setCursor(0, 0);
  57. lcd.print("P-L:");
  58. lcd.setCursor(0, 1);
  59. for(y=0;y<5;y++)
  60. {
  61. val[y]=digitalRead(place[y]);
  62. if(val[y]==1)
  63.  
  64. {
  65. lcd.print(y+1);
  66. }
  67. }
  68. lcd.print(" ");
  69. valin=digitalRead(in);
  70. valout=digitalRead(out);
  71. if(count>=6)
  72. {
  73. count=6;myservo.write(0);delay(1000);myservo.detach();
  74. lcd.setCursor(5, 1);
  75. lcd.print(" FULL");
  76.  
  77. }
  78. if(valout==LOW)
  79. {
  80. for(pos=51 ; pos>=0; pos--)
  81. {myservo.write(pos);delay(30);
  82. }
  83. while(valout==LOW) {
  84. valout=digitalRead(out);
  85.  
  86. }
  87. count++;
  88. if(count<7){}
  89. delay(1000);
  90. for(pos =0; pos<=51; pos++)
  91. {myservo.write(pos);delay(30);
  92. }
  93. }
  94.  
  95.  
  96. if (valin==LOW)
  97. {
  98. myservo.attach(5);
  99. for(pos=51 ; pos>=0; pos--){myservo.write(pos);delay(30);}
  100. while(valin==LOW)
  101. {
  102. valin=digitalRead(in);}
  103. count--;
  104. if(count<=0){count=0;}
  105. delay(1000);
  106. for(pos=0; pos<=51; pos++) {myservo.write(pos);delay(30);}
  107. }
  108. lcd.setCursor(10, 1);
  109. lcd.print(" cnt:");
  110. lcd.print(count);
  111. if(count>=6){
  112. lcd.setCursor(5, 1);
  113. lcd.print(" FULL " );}
  114. }`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement