Revathi Kannan
Published

Auto_Power_Controller(APC)

An IoT device to automatically switch on/off electronic appliances based on the availability of human beings, especially in public services.

IntermediateProtip6 hours4,332
Auto_Power_Controller(APC)

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×1
9V battery (generic)
9V battery (generic)
×1
Resistor 221 ohm
Resistor 221 ohm
×1
Relay (generic)
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Arduino UNO
Arduino UNO
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

APC

Code

Auto_Power_Controller

Python
int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status

void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input

Serial.begin(9600);
}

void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
// we have just turned on
Serial.println("Motion detected!");
// We only want to print on the output change, not state
pirState = HIGH;
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned of
Serial.println("Motion ended!");
// We only want to print on the output change, not state
pirState = LOW;
}
}
}

Credits

Revathi Kannan

Revathi Kannan

2 projects • 13 followers
Application Developer : A| - BlockChain - Mainframes - Vision plus expertise - IBM Watson - IBM Code Challenge Winner 2018 (Top 3/India)

Comments