Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
Software apps and online services | ||||||
|
Sometimes due to old age, patients forget about their medications (drugs), so I made an easy reminder for our families or whomever, with just a tag and LED or LCD (not included) to show when it is time to take medication.
You should read your tag first and have the tag ID and copy it to the code of the medication's code example: Mycard (36x 3bx ...).
After that you should connect LEDs.
And if you would like to add an LCD, just replace Serial.print
with LCD.print
and add the LCD library.
/*
* RFID Module RC522
* Simple Project:- Arduino will read RFID Tag and Display To the Serial Monitor!
*
* RFID RC522 and Arduino Uno Pin Configuration
*
* RFID RC522 Arduino Uno
* SS/SDA D10
* SCK D13
* MOSI D11
* MISO D12
* IRQ Not Connected
* GND GND
* RST D9
* 3.3V 3.3V
*/
#include <SPI.h>
#include <RFID.h>
#define SS_PIN 10
#define RST_PIN 9
#define Red_LED 6
#define Green_LED1 5
#define Green_LED2 4
#define Green_LED3 3
RFID rfid(SS_PIN, RST_PIN);
//Unique ID of RFID Tag, which you want to give access.
int My_RFID_Tag[5] = {0x39,0x57,0x10,0xBB,0xC5}; //after reading carte1
int My_RFID_Tag1[5] = {0x6C,0x88,0xE1,0x2B,0x2E}; //carte 2
//variable to hold your Access_card
boolean My_Card = false;
boolean My_Card1 = false;
void setup()
{
// put your setup code here, to run once:
//set the pins as an input/output
pinMode(Red_LED,OUTPUT);
pinMode(Green_LED1,OUTPUT);
pinMode(Green_LED2,OUTPUT);
pinMode(Green_LED3,OUTPUT);
Serial.begin(9600);
SPI.begin();
rfid.init();
}
void loop(){
//First Assume detected card(Or tag) is My_Card,
//Then later we will check is it My_Card or not!
My_Card = true;
My_Card1 = true;
//Check if any RFID Tags Detected or not?
if (rfid.isCard()) {
//if RFID Tag is detected, check for the Unique ID,
//and print it on the Serial Window
if (rfid.readCardSerial()) {
Serial.println("Card found");
//Unique id is 5 Digit Number.
//Printing in HEX for better Understanding
for( int i = 0; i < 5; i++ )
{
Serial.print(rfid.serNum[i], HEX);
Serial.print(" ");
}
delay(100);
//Compare this RFID Tag Unique ID with your My_RFID_Tag's Unique ID
for(int i = 0; i < 5; i++)
{
//if any one Unique ID Digit is not matching,
//then make My_Card = false and come out from loop
//No need to check all the digit!
if( My_RFID_Tag[i] != rfid.serNum[i] )
{
My_Card = false;
break;
}
if( My_RFID_Tag1[i] != rfid.serNum[i] )
{
My_Card1 = false;
break;
}
}
Serial.println();
if(My_Card){
Serial.println("Mme this is your medication ");
Serial.println("Breakfast - Lunch - Dinner ");
//Turn on the Green LED as an indication of permission is given
//to access the room.
digitalWrite(Green_LED1,HIGH);
digitalWrite(Green_LED2,HIGH);
digitalWrite(Green_LED3,HIGH);
digitalWrite(Red_LED,LOW);
delay(3000);
/* If we have the same ID, just write a dot. */
Serial.print("...");
digitalWrite(Green_LED1,LOW);
digitalWrite(Green_LED2,LOW);
digitalWrite(Green_LED3,LOW);
digitalWrite(Red_LED,HIGH);
} else if(My_Card1){
Serial.println("MR this is your medication ");
Serial.println("breakfast - Dinner ");
//Turn on the Green LED as an indication of permission is given
//to access the room.
digitalWrite(Green_LED1,HIGH);
digitalWrite(Green_LED2,LOW);
digitalWrite(Green_LED3,HIGH);
digitalWrite(Red_LED,LOW);
delay(3000);
/* If we have the same ID, just write a dot. */
Serial.print("...");
digitalWrite(Green_LED1,LOW);
digitalWrite(Green_LED2,LOW);
digitalWrite(Green_LED3,LOW);
digitalWrite(Red_LED,HIGH);
} else {
/* If we have the same ID, just write a dot. */
Serial.print("...");
digitalWrite(Green_LED1,LOW);
digitalWrite(Green_LED2,LOW);
digitalWrite(Green_LED3,LOW);
digitalWrite(Red_LED,HIGH);
return;
}
}
}
rfid.halt();
}
/**
* Read a card using a mfrc522 reader on your SPI interface
* Pin layout should be as follows (on Arduino Uno):
* MOSI: Pin 11 / ICSP-4
* MISO: Pin 12 / ICSP-1
* SCK: Pin 13 / ISCP-3
* SS: Pin 10
* RST: Pin 9
*
* Script is based on the script of Miguel Balboa.
* New cardnumber is printed when card has changed. Only a dot is printed
* if card is the same.
*
* @version 0.1
* @author Henri de Jong
* @since 06-01-2013
*/
#include <SPI.h>
#include <RFID.h>
#define SS_PIN 10
#define RST_PIN 9
RFID rfid(SS_PIN, RST_PIN);
// Setup variables:
int serNum0;
int serNum1;
int serNum2;
int serNum3;
int serNum4;
void setup()
{
Serial.begin(9600);
SPI.begin();
rfid.init();
}
void loop()
{
if (rfid.isCard()) {
if (rfid.readCardSerial()) {
if (rfid.serNum[0] != serNum0
&& rfid.serNum[1] != serNum1
&& rfid.serNum[2] != serNum2
&& rfid.serNum[3] != serNum3
&& rfid.serNum[4] != serNum4
) {
/* With a new cardnumber, show it. */
Serial.println(" ");
Serial.println("Card found");
serNum0 = rfid.serNum[0];
serNum1 = rfid.serNum[1];
serNum2 = rfid.serNum[2];
serNum3 = rfid.serNum[3];
serNum4 = rfid.serNum[4];
//Serial.println(" ");
Serial.println("Cardnumber:");
Serial.print("Dec: ");
Serial.print(rfid.serNum[0],DEC);
Serial.print(", ");
Serial.print(rfid.serNum[1],DEC);
Serial.print(", ");
Serial.print(rfid.serNum[2],DEC);
Serial.print(", ");
Serial.print(rfid.serNum[3],DEC);
Serial.print(", ");
Serial.print(rfid.serNum[4],DEC);
Serial.println(" ");
Serial.print("Hex: ");
Serial.print(rfid.serNum[0],HEX);
Serial.print(", ");
Serial.print(rfid.serNum[1],HEX);
Serial.print(", ");
Serial.print(rfid.serNum[2],HEX);
Serial.print(", ");
Serial.print(rfid.serNum[3],HEX);
Serial.print(", ");
Serial.print(rfid.serNum[4],HEX);
Serial.println(" ");
} else {
/* If we have the same ID, just write a dot. */
Serial.print(".");
}
}
}
rfid.halt();
}
Comments