Danny van den Brande
Published © CC BY-SA

Arduino - Panic Alarm, Relay With ALARM. KY-019 Example

Hello world! Today I made an example on the KY_019 Relay module. In my video I use an alarm with a strobe attached to it.

BeginnerProtip1 hour1,904
Arduino - Panic Alarm, Relay With ALARM. KY-019 Example

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
KY-019 1 Channel relay
×1
KY-004 Button Module.
×1
Alarm strobe + a power source 12v
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Schematics

Schematic

Code

KY-019_Relay_Module_Example.ino

Arduino
In this example i show you how to use the KY-019 Relay with the KY-004 button module.
/*
Author: Danny van den Brande, Arduinosensors.nl. BlueCore Tech.
In this example i show you how to use the KY-019 Relay with the KY-004 button module.
I attached a 12v alarm siren with strobe. to the relay in the video but 
you can add anything you like offcourse. the Idea now is that
it is functioning as a alarm/panic alarm that can only be turned off when reset.
If you want it to work otherwise you need to Uncomment the commented part 
in the void loop section of the code.
*/
int Relay = 3;
int Button = 10;
boolean val;

void setup() {
  pinMode(Relay, OUTPUT);
  pinMode(Button, INPUT);
  
}

void loop() {
  val = digitalRead (Button);
    if (val == 0)
    {
    digitalWrite (Relay, HIGH);
//    }      //Uncomment if you want the relay only
//    else   //to be on when holding the button.
//    {      //now the alarm need to be reset to turn it off.
//    digitalWrite (Relay, LOW);  
  }
}

Credits

Danny van den Brande
36 projects • 109 followers
"Hello world."
Contact

Comments

Please log in or sign up to comment.