Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <stdio.h>
  2. int state = 0;
  3. int numShots1 =1;
  4. int numShots2 =1;
  5. int counter1 =0;
  6. int counter2 =0;
  7. const int pin2 = 2;
  8. const int pin3 = 3;
  9.  
  10. void setup()
  11.  
  12. {
  13.  
  14. Serial.begin(9600);
  15. }
  16. void loop()
  17. {
  18. if ((digitalRead(pin2) == LOW && state == 0) && (numShots1 > counter1)){
  19.  
  20. Serial.print("\r");
  21. delay(1500);
  22. Serial.print("AT+CMGF=1\r");
  23. delay(1500);
  24.  
  25. Serial.print("AT+CMGS=\"+64274035750\"\r");
  26. delay(1500);
  27.  
  28. Serial.print("FILL THE TANK");
  29. delay(1500);
  30. Serial.write(0x1A);
  31. delay(1500);
  32. // while (digitalRead(pin2)== LOW && state == 0)
  33. counter1++;
  34. state == 1;
  35.  
  36. }
  37. if (digitalRead(pin2) == HIGH && state == 0)
  38. {
  39. counter1 = 0;
  40. }
  41.  
  42.  
  43.  
  44. if ((digitalRead(pin3) == HIGH && state == 0) && (numShots2 > counter2)) {
  45.  
  46.  
  47. Serial.print("\r");
  48. delay(1500);
  49. Serial.print("AT+CMGF=1\r");
  50. delay(1500);
  51.  
  52. Serial.print("AT+CMGS=\"+64274035750\"\r");
  53. delay(1500);
  54.  
  55. Serial.print("TANK FULL");
  56. delay(1500);
  57.  
  58. Serial.write(0x1A);
  59. delay(1500);
  60. // while (digitalRead(pin3) == HIGH && state == 0)
  61. counter2++;
  62. state == 1;
  63.  
  64. }
  65. if (digitalRead(pin3) == LOW && state == 0)
  66.  
  67. {
  68. counter2 =0;
  69.  
  70. }
  71. else {
  72. state = 0; }
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement