Created
April 21, 2015 16:41
-
-
Save rogiervandenberg/48b9b08df8c29d3fe5c4 to your computer and use it in GitHub Desktop.
Checks my front door status. Sends status over RF-communication.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//To make more serial ports | |
#include <SoftwareSerial.h> | |
SoftwareSerial remoteSerial(2, 3); //Use pins 2 and 3 to connect the Serial connection | |
const int light = 13; //output and light | |
const int reedPin = 5; //read info from the Reed | |
//vars | |
int output = LOW; | |
int readState = LOW; | |
void setup() | |
{ | |
pinMode(reedPin,INPUT); | |
pinMode(light,OUTPUT); | |
Serial.begin(9600); // Debugging only | |
remoteSerial.begin(9600); | |
} | |
void loop() | |
{ | |
readState = digitalRead(reedPin); | |
if(readState) | |
{ | |
digitalWrite(light,LOW); | |
Serial.println("Deur open"); | |
remoteSerial.println("O"); | |
} | |
else | |
{ | |
digitalWrite(light,HIGH); | |
Serial.println("Deur dicht"); | |
remoteSerial.println("C"); | |
} | |
delay(2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment