Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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