Skip to content

Instantly share code, notes, and snippets.

@rogiervandenberg
Created April 21, 2015 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogiervandenberg/48b9b08df8c29d3fe5c4 to your computer and use it in GitHub Desktop.
Save rogiervandenberg/48b9b08df8c29d3fe5c4 to your computer and use it in GitHub Desktop.
Checks my front door status. Sends status over RF-communication.
//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