SHARE
TWEET

Untitled

a guest Dec 8th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. unsigned long interval=120000; // 2 MENIT
  2. unsigned long previousMillis=0; // millis() returns an unsigned long.
  3.  
  4. #define RELAY 12
  5. #define SENSOR1 11
  6.  
  7. void setup() {
  8.  pinMode(SENSOR1, INPUT);
  9.  pinMode(RELAY, OUTPUT);
  10. }
  11.  
  12. void loop() {
  13. if(SENSOR1==HIGH){
  14.  unsigned long currentMillis = millis(); // grab current time
  15.  if ((unsigned long)(currentMillis - previousMillis) >= interval) {
  16.    digitalWrite(RELAY, HIGH); // AKTIFKAN RELAY
  17.    previousMillis = millis();
  18.  }
  19. }
  20.  
  21. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top