|
/* |
|
Florin Simedru |
|
Complete project details at https://automatic-house.blogspot.com |
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
of this software and associated documentation files. |
|
|
|
The above copyright notice and this permission notice shall be included in all |
|
copies or substantial portions of the Software. |
|
*/ |
|
|
|
#include "RCSwitch.h" |
|
// constants won't change. They're used here to set pin numbers: |
|
const int buttonPin = 23; // the number of the pushbutton pin |
|
const int ledPin = 2; // the number of the LED pin |
|
const int BellPin = 22; // the number of the doorbell pin |
|
RCSwitch mySwitch = RCSwitch(); |
|
#define CODE_BT1 0xC10208 // doorbell activation code |
|
// variables will change: |
|
int buttonState = 0; // variable for reading the pushbutton status |
|
|
|
void setup() { |
|
Serial.begin(115200); |
|
// initialize the LED pin as an output: |
|
pinMode(ledPin, OUTPUT); |
|
// initialize the pushbutton pin as an input: |
|
pinMode(buttonPin, INPUT); |
|
pinMode(12, INPUT_PULLUP); |
|
mySwitch.enableTransmit(BellPin); |
|
mySwitch.setProtocol(1, 208); |
|
} |
|
|
|
void loop() {// read the state of the pushbutton value: |
|
buttonState = digitalRead(buttonPin); |
|
|
|
// check if the pushbutton is pressed. If it is, the buttonState is HIGH: |
|
|
|
if (buttonState == HIGH) |
|
{ |
|
Serial.print("buton = "); |
|
Serial.println(buttonState); |
|
// turn LED on: |
|
digitalWrite(ledPin, HIGH); |
|
mySwitch.send(CODE_BT1 , 24); |
|
delay(50); |
|
mySwitch.send(CODE_BT1 , 24); |
|
delay(50); |
|
mySwitch.send(CODE_BT1 , 24); |
|
delay(50); |
|
mySwitch.send(CODE_BT1 , 24); |
|
delay(50); |
|
mySwitch.send(CODE_BT1 , 24); |
|
delay(50); |
|
mySwitch.send(CODE_BT1 , 24); |
|
delay(50); |
|
mySwitch.send(CODE_BT1 , 24); |
|
} |
|
else |
|
{ |
|
// turn LED off: |
|
digitalWrite(ledPin, LOW); |
|
} |
|
} |