Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Sim800l.h"
- Sim800l Sim800l;
- #define RST 4
- #define SEN 8
- bool hold = false;
- bool dt_sensor;
- unsigned cur_time, old_time;
- void setup() {
- // put your setup code here, to run once:
- pinMode(RST, OUTPUT);
- pinMode(SEN,INPUT_PULLUP);
- digitalWrite(RST, LOW); delay(1000);
- digitalWrite(RST, HIGH); delay(1000);
- Serial.begin(115200);
- Sim800l.begin();
- delay(10000);
- //Sim800l.sendSms("081263920524", "system bekerja dengan baik");
- Serial.println("system mulai");
- }
- void loop() {
- // put your main code here, to run repeatedly:
- cur_time = millis();
- if(cur_time - old_time >= 1000){
- baca_sensor();
- Sim800l.signalQuality();
- old_time = cur_time;
- }
- }
- void baca_sensor(){
- dt_sensor = digitalRead(SEN);
- Serial.print("sensor= ");
- Serial.println(dt_sensor);
- if(dt_sensor == true){
- if(hold == false){
- hold = true;
- kirim_sms();
- }
- }else{
- hold = false;
- }
- }
- void kirim_sms(){
- Serial.println("kirim sms");
- Sim800l.sendSms("081263920524", "Ada tindakan pencurian,\n SEGERA CHECK!!!");
- delay(3000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement