21 October 2019

Communication: Schedule Reminder


For this communication project, I created an interactive system that provides the correct user with access to their home and current schedule. To create this, I used an RFID reader to detect the user ID through a key, this could potentially be set to work with several keys for a larger family. If the key presented is the correct one, it will turn on the house lights and welcome the user with a message through an LCD display. This screen would ideally be larger and embedded into the user’s home for a more ubiquitous experience. If an incorrect user is detected, a message of intrusion is shown on the LCD display and the person does not have access to the rest of the functions. In addition to this, once a correct user is detected, the system invites the user to input, through the computer, the current time of the day and scan their key again to show them their scheduled activities for that moment. Ideally, this could be expanded with a clock to reduce the need of the user’s input of the time and make it more automatic once they place their keys in the correct place.







//House lights
const int lights = A0;
//Box light
const int boxLight = A2;
//LCD
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
//RFID
#include <SPI.h>
#include <MFRC522.h>
const int resetPin = 9;
const int ssPin = 10;
MFRC522 mfrc522(ssPin, resetPin);
int input = 0;
int oldKey = 0;
int newKey = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//LED's
pinMode(lights, OUTPUT);
pinMode(boxLight, OUTPUT);
digitalWrite(boxLight, HIGH);
//LCD
lcd.begin(16, 2);
//RFID
SPI.begin();
mfrc522.PCD_Init();
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
cardReader();
}
void welcome(){
lcd.clear();
lcd.setCursor(14,0);
lcd.print("Welcome Home");
//scroll in from right to left
for (int positionCounter = 0; positionCounter < 12; positionCounter++) {
lcd.scrollDisplayLeft();
delay(100);
}
}
void boxLed(){
digitalWrite(lights, LOW);
digitalWrite(boxLight, HIGH);
}
void warning(){
digitalWrite(boxLight, HIGH);
delay(500);
digitalWrite(boxLight, LOW);
delay(500);
digitalWrite(boxLight, HIGH);
delay(500);
digitalWrite(boxLight, LOW);
delay(500);
digitalWrite(boxLight, HIGH);
delay(500);
digitalWrite(boxLight, LOW);
delay(500);
digitalWrite(boxLight, HIGH);
}
void scrollOut(){
for (int positionCounter = 0; positionCounter < 16; positionCounter ++) {
lcd.scrollDisplayLeft();
delay(10);
}
lcd.clear();
}
void houseLed(){
digitalWrite(lights, HIGH);
digitalWrite(boxLight, LOW);
}
void cardReader(){
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Read UID and grant access if it's correct.
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
if (content.substring(1) == "06 92 60 a3") //change here the UID of the card/cards that you want to give access
{ newKey = 1;
}
else{
newKey = 0;
boxLed();
Serial.println(" Intruder detected. Access denied. ");
lcd.clear();
lcd.setCursor(0,0);
lcd.print("!!!!Intruder!!!!");
warning();
delay(3000);
}
if (oldKey == 0 && newKey == 1){
houseLed();
welcome();
inputMessage();
}
mfrc522.PICC_HaltA();
}
void inputMessage(){
houseLed();
Serial.println("");
Serial.println(" Please choose the current time to check your schedule: ");
Serial.println(" 1 - Morning ");
Serial.println(" 2 - Noon ");
Serial.println(" 3 - Night ");
Serial.println(" Then scan your key again. ");
//Serial Reader
if(Serial.available() > 0) {
char c = Serial.read();
//scrollOut();
if(c == '1'){
lcd.clear();
Serial.println("");
Serial.println(" Morning");
lcd.setCursor(1,0);
lcd.print("It's Gym Time!");
}
if(c == '2'){
lcd.clear();
Serial.println("");
Serial.println(" Noon");
lcd.setCursor(1,0);
lcd.print("Ready for work?");
}
if(c == '3'){
lcd.clear();
Serial.println("");
Serial.println(" Night");
lcd.setCursor(1,0);
lcd.print("Time to party!");
}
}
delay(5000);
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.