0% found this document useful (0 votes)
35 views

Diy P4 D1 Call System Control

This document describes an Arduino sketch for a DIY PIR motion sensor security system with 4 LEDs and 2 push buttons. The sketch defines pin assignments for the components, sets the pins as inputs or outputs, and contains the main loop code. The loop code checks the states of the push buttons and PIR sensor to control the LEDs by turning them on/off or fading them up and down.

Uploaded by

calvin ferian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Diy P4 D1 Call System Control

This document describes an Arduino sketch for a DIY PIR motion sensor security system with 4 LEDs and 2 push buttons. The sketch defines pin assignments for the components, sets the pins as inputs or outputs, and contains the main loop code. The loop code checks the states of the push buttons and PIR sensor to control the LEDs by turning them on/off or fading them up and down.

Uploaded by

calvin ferian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DIY P4 D1 CALL SYSTEM

CONTROL

{
int pinLed1 = 7;
Serial.begin(9600);
int pinLed2 = 9;
pinMode(switchPin1, INPUT);
int pinLed3 = 10;
pinMode(switchPin2, INPUT);
int pinLed4 = 11;
pinMode(pir, INPUT);
int pir = 12;
pinMode(pinLed1, OUTPUT);
int switchPin1 = 2;
pinMode(pinLed2, OUTPUT);
int switchPin2 = 4;
pinMode(pinLed3, OUTPUT);
int kondisiPushButton1 = 0;
pinMode(pinLed4, OUTPUT);
int kondisiPushButton2 = 0;
}
void setup()
delay(500);

void loop(){ }

kondisiPushButton1 = else if(kondisiPushButton1 == HIGH &&


digitalRead(switchPin1); kondisiPushButton2 == LOW){

kondisiPushButton2 = for(int nilaiFade = 0; nilaiFade<=255;


digitalRead(switchPin2); nilaiFade +=5){

int pirVal = digitalRead(pir); digitalWrite(pinLed4, HIGH);

Serial.print("nilaiPir = "); analogWrite(pinLed1, nilaiFade);

Serial.println(pirVal); analogWrite(pinLed2, nilaiFade);

analogWrite(pinLed3, nilaiFade);

if(pirVal == HIGH) delay(200);

{ }

if(kondisiPushButton1 == LOW && for(int nilaiFade = 255; nilaiFade >=0;


kondisiPushButton2 == HIGH){ nilaiFade -=5){

digitalWrite (pinLed4,HIGH); digitalWrite(pinLed4, LOW);

delay(0); analogWrite(pinLed1, nilaiFade);

digitalWrite(pinLed3, HIGH); analogWrite(pinLed2, nilaiFade);

delay(500); analogWrite(pinLed3, nilaiFade);

digitalWrite(pinLed3, LOW); }

delay(500); }

digitalWrite(pinLed2, HIGH);

delay(500); }

digitalWrite(pinLed2, LOW); else{

delay(500); digitalWrite(pinLed1, LOW);

digitalWrite(pinLed1, HIGH); digitalWrite(pinLed2, LOW);

delay(500); digitalWrite(pinLed3, LOW);

digitalWrite(pinLed1, LOW); digitalWrite(pinLed4, LOW);


}

You might also like