Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int level1 = 5;
- int level2 = 7;
- int level3 = 8;
- int sensorPintu1;
- int sensorPintu2;
- int sensorPintu3;
- int hold_key = 0;
- void kirimSMS();
- void kirimSMS2();
- void kirimSMS3();
- void read_sensor();
- void smsPintu1();
- void smsPintu2();
- void smsPintu3();
- void setup() {
- // put your setup code here, to run once:
- pinMode(level1,INPUT);
- pinMode(level2,INPUT);
- pinMode(level3,INPUT);
- Serial.begin(115200);
- delay(2000);
- delay(2000);
- delay(2000);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- read_sensor();
- delay(1000);
- }
- void read_sensor(){
- sensorPintu1 = digitalRead(level1);
- sensorPintu2 = digitalRead(level2);
- sensorPintu3 = digitalRead(level3);
- if ( sensorPintu1 == 0 && sensorPintu2 == 0 && sensorPintu3 == 0 ){
- hold_key = 0;
- Serial.println("SYSTEM AMAN, SENSOR MEMBACA");
- }
- else if ( sensorPintu1 == 1 && sensorPintu2 == 0 && sensorPintu3 == 0 ){
- if ( hold_key == 0){
- //isi pesan sms disini
- kirimSMS();
- smsPintu1();
- kirimSMS2();
- smsPintu1();
- kirimSMS3();
- smsPintu1();
- hold_key = 1;
- }
- }
- else if ( sensorPintu1 == 1 && sensorPintu2 == 1 && sensorPintu3 == 0 ){
- if ( hold_key == 1){
- //isi pesan sms disini
- kirimSMS();
- smsPintu2();
- kirimSMS2();
- smsPintu2();
- kirimSMS3();
- smsPintu2();
- hold_key = 2;
- }
- }
- else if ( sensorPintu1 == 1 && sensorPintu2 == 1 && sensorPintu3 == 1 ){
- if ( hold_key == 2){
- //isi pesan sms disini
- kirimSMS();
- smsPintu3();
- kirimSMS2();
- smsPintu3();
- kirimSMS3();
- smsPintu3();
- hold_key = 3;
- }
- }
- }
- void kirimSMS(){
- delay(1000);
- Serial.print("AT\r\n");
- delay(2000);
- Serial.print("AT+CMGF=1\r\n");
- delay(2000);
- Serial.print("AT+CMGS=\"+6282168073459\"\r\n");
- delay(2000);
- }
- void kirimSMS2(){
- delay(1000);
- Serial.print("AT\r\n");
- delay(2000);
- Serial.print("AT+CMGF=1\r\n");
- delay(2000);
- Serial.print("AT+CMGS=\"+6285270466336\"\r\n");
- delay(2000);
- }
- void kirimSMS3(){
- delay(1000);
- Serial.print("AT\r\n");
- delay(2000);
- Serial.print("AT+CMGF=1\r\n");
- delay(2000);
- Serial.print("AT+CMGS=\"+6282256819064\"\r\n");
- delay(2000);
- }
- void smsPintu1(){
- Serial.print("WARNING !!!\r\n");
- Serial.print("PINTU 1\r\n");
- Serial.print("LIHAT KERUANGAN 1\r\n");
- delay(1500);
- Serial.print(char(26));
- }
- void smsPintu2(){
- Serial.print("WARNING !!!\r\n");
- Serial.print("PINTU 2\r\n");
- Serial.print("LIHAT KERUANGAN 2\r\n");
- delay(1500);
- Serial.print(char(26));
- }
- void smsPintu3(){
- Serial.print("WARNING !!!\r\n");
- Serial.print("PINTU 3\r\n");
- Serial.print("LIHAT KERUANGAN 3\r\n");
- delay(1500);
- Serial.print(char(26));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement