SHARE
TWEET

sms alarm pintu sim800

mikroavr Apr 21st, 2019 156 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int level1 = 5;
  2. int level2 = 7;
  3. int level3 = 8;
  4.  
  5. int sensorPintu1;
  6. int sensorPintu2;
  7. int sensorPintu3;
  8.  
  9. int hold_key = 0;
  10.  
  11. void kirimSMS();
  12. void kirimSMS2();
  13. void kirimSMS3();
  14.  
  15. void read_sensor();
  16. void smsPintu1();
  17. void smsPintu2();
  18. void smsPintu3();
  19.  
  20. void setup() {
  21. // put your setup code here, to run once:
  22. pinMode(level1,INPUT);
  23. pinMode(level2,INPUT);
  24. pinMode(level3,INPUT);
  25. Serial.begin(115200);
  26. delay(2000);
  27. delay(2000);
  28. delay(2000);
  29. }
  30.  
  31. void loop() {
  32. // put your main code here, to run repeatedly:
  33. read_sensor();
  34. delay(1000);
  35. }
  36.  
  37. void read_sensor(){
  38. sensorPintu1 = digitalRead(level1);
  39. sensorPintu2 = digitalRead(level2);
  40. sensorPintu3 = digitalRead(level3);
  41.  
  42. if ( sensorPintu1 == 0 && sensorPintu2 == 0 && sensorPintu3 == 0 ){
  43. hold_key = 0;
  44. Serial.println("SYSTEM AMAN, SENSOR MEMBACA");
  45.  
  46. }
  47.  
  48. else if ( sensorPintu1 == 1 && sensorPintu2 == 0 && sensorPintu3 == 0 ){
  49. if ( hold_key == 0){
  50. //isi pesan sms disini
  51. kirimSMS();
  52. smsPintu1();
  53.  
  54. kirimSMS2();
  55. smsPintu1();
  56.  
  57. kirimSMS3();
  58. smsPintu1();
  59. hold_key = 1;
  60. }
  61. }
  62.  
  63. else if ( sensorPintu1 == 1 && sensorPintu2 == 1 && sensorPintu3 == 0 ){
  64.  
  65. if ( hold_key == 1){
  66. //isi pesan sms disini
  67. kirimSMS();
  68. smsPintu2();
  69.  
  70. kirimSMS2();
  71. smsPintu2();
  72.  
  73. kirimSMS3();
  74. smsPintu2();
  75.  
  76. hold_key = 2;
  77. }
  78. }
  79.  
  80. else if ( sensorPintu1 == 1 && sensorPintu2 == 1 && sensorPintu3 == 1 ){
  81. if ( hold_key == 2){
  82. //isi pesan sms disini
  83. kirimSMS();
  84. smsPintu3();
  85.  
  86. kirimSMS2();
  87. smsPintu3();
  88.  
  89. kirimSMS3();
  90. smsPintu3();
  91.  
  92. hold_key = 3;
  93. }
  94. }
  95. }
  96.  
  97. void kirimSMS(){
  98. delay(1000);
  99. Serial.print("AT\r\n");
  100. delay(2000);
  101. Serial.print("AT+CMGF=1\r\n");
  102. delay(2000);
  103. Serial.print("AT+CMGS=\"+6282168073459\"\r\n");
  104. delay(2000);
  105. }
  106.  
  107. void kirimSMS2(){
  108. delay(1000);
  109. Serial.print("AT\r\n");
  110. delay(2000);
  111. Serial.print("AT+CMGF=1\r\n");
  112. delay(2000);
  113. Serial.print("AT+CMGS=\"+6285270466336\"\r\n");
  114. delay(2000);
  115.  
  116. }
  117. void kirimSMS3(){
  118. delay(1000);
  119. Serial.print("AT\r\n");
  120. delay(2000);
  121. Serial.print("AT+CMGF=1\r\n");
  122. delay(2000);
  123. Serial.print("AT+CMGS=\"+6282256819064\"\r\n");
  124. delay(2000);
  125.  
  126. }
  127.  
  128. void smsPintu1(){
  129. Serial.print("WARNING !!!\r\n");
  130. Serial.print("PINTU 1\r\n");
  131. Serial.print("LIHAT KERUANGAN 1\r\n");
  132. delay(1500);
  133. Serial.print(char(26));
  134. }
  135.  
  136. void smsPintu2(){
  137. Serial.print("WARNING !!!\r\n");
  138. Serial.print("PINTU 2\r\n");
  139. Serial.print("LIHAT KERUANGAN 2\r\n");
  140. delay(1500);
  141. Serial.print(char(26));
  142. }
  143.  
  144. void smsPintu3(){
  145. Serial.print("WARNING !!!\r\n");
  146. Serial.print("PINTU 3\r\n");
  147. Serial.print("LIHAT KERUANGAN 3\r\n");
  148. delay(1500);
  149. Serial.print(char(26));
  150. }
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