/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the serial monitor
This example code is in the public domain.
*/
#define SYSTEM_ON 6
#define PANEL_POWER 3
#define PIR_Sensor 11
int buttonstate = 0;
int count = 0;
int PIR_Value = 0;
void setup() {
Serial.begin(9600);
pinMode(PIR_Sensor, INPUT);
pinMode(PANEL_POWER, OUTPUT);
pinMode(SYSTEM_ON, INPUT);
// attachInterrupt(digitalPinToInterrupt(SYSTEM_ON), INTER, RISING);
}
void loop() {
buttonstate = digitalRead(SYSTEM_ON);
if (buttonstate == HIGH && count == 0){
count = 1;
}
if (count == 1){
PIR_Value = digitalRead(PIR_Sensor);
if (PIR_Value == HIGH){
Serial.println("Motion Detected!");
digitalWrite(PANEL_POWER, HIGH);
} else if (PIR_Value == LOW){
Serial.println("No Motion Detected!");
digitalWrite(PANEL_POWER, LOW);
}
delay(500);
}
}
/*void INTER(){
count +=1;
}*/