ISN (International Social Networking Services - Interactive Apps and Websites)


All Our projects

Electronic Pet Door - Arduino Nano LCD RFID Security Door


Electronic Pet Door, products and first test

 


How can we easily realize a project with Arduino electronics to create a pet door for the exit and entry of your cat but not the neighbor! A new version will be bienôt day!
Objects used for this project:
2 colored LEDs.
RFID card reader induction.
1 servo motor.
1 Arduino development board.
1 ProtoShield extension.
2 decks of experimentation.
Resitors, jump cable and USB power cable 1.

Final product online test


This product is an invention, do not copy without specifying the origin and product inventor.
The viedo is made for educational title and any copy for commercial reason isn't allowed. Only copies for personal use are allowed.

The complete Arduino code source:


#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h> 
#include <Stepper.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

#define I2C_ADDR 0x27 // <<- Add your address here.
#define Rs_pin 0
#define Rw_pin 1
#define En_pin 2
#define BACKLIGHT_PIN 3
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

Servo myservo;
#define RST_PIN		9		// 
#define SS_PIN		10		//
MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance

String read_rfid;
String ok_rfid_1="c4b256f";
String ok_rfid_n="";

int peezo = 5;
int ledPin1 = 7;
int ledPin2 = 6,butPin=8; 

int servopin = 4;
int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin
int posClosed=30;
int posOpened=120;

int pos = 0,newcard=0;

//stepper
#define STEPS  32   // Number of steps per revolution of Internal shaft
int  Steps2Take;  // 2048 = 1 Revolution
// In1, In2, In3, In4 in the sequence 1-3-2-4
//Stepper small_stepper(STEPS, 2,3,4,5);

void setup() {
	Serial.begin(9600);		// Initialize serial communications with the PC
	while (!Serial);		// Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
	
	SPI.begin();			// Init SPI bus
	mfrc522.PCD_Init();		// Init MFRC522
	ShowReaderDetails();	// Show details of PCD - MFRC522 Card Reader details
	//Serial.println(F("Scan PICC to see UID, type, and data blocks..."));
  pinMode(ledPin1,OUTPUT);
  pinMode(ledPin2,OUTPUT);
  pinMode(peezo, OUTPUT); digitalWrite(peezo, LOW);
  pinMode(butPin, INPUT); digitalWrite(butPin, LOW);
  myservo.attach(servopin);
  myservo.write(posClosed);
  lcd.clear();
  lcd.begin (7,2);
  // LCD Backlight ON
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home ();
  lcd.print("Chatiere ready");
  flashg(2,200);
}
void dump_byte_array(byte *buffer,byte bufferSize){
  read_rfid="";
  for(byte i=0;i<bufferSize;i++){
    read_rfid=read_rfid+String(buffer[i],HEX);
  }
}
void flashg(int howmany,int temps){
  for (int i=0;i<howmany;i++){
    digitalWrite(ledPin2,HIGH);digitalWrite(peezo,HIGH);delay(temps);digitalWrite(ledPin2,LOW);digitalWrite(peezo,LOW);delay(temps);
  }
}
void flashr(int howmany,int temps){
  for (int i=0;i<howmany;i++){
    digitalWrite(ledPin1,HIGH);digitalWrite(peezo,HIGH);delay(temps);digitalWrite(ledPin1,LOW);digitalWrite(peezo,LOW);delay(temps);
  }
}
void open_lock(){
  flashg(2,100);
  myservo.write(posOpened); delay(6000);myservo.write(posClosed);
}
void dont_open(){
  flashr(2,300);
  myservo.write(posClosed);
  //small_stepper.setSpeed(700); //Max seems to be 700
  //Steps2Take  =  200;  // Rotate CW
  //small_stepper.step(Steps2Take);
}
void loop() {
  if(digitalRead(butPin)==HIGH){
    if(newcard==0){
      newcard=1;
      lcd.clear();
      lcd.setCursor (0,0);
      lcd.print("New card?");
      lcd.setCursor (0,1);
      lcd.print("scan it now");
    }else{
      ok_rfid_1=ok_rfid_n;
      lcd.clear();
      lcd.setCursor (0,0);
      lcd.print("New card");
      lcd.setCursor (0,1);
      lcd.print("successfully saved");
      newcard=0;
    }
    flashg(1,100);
  }
	// Look for new cards
	if ( ! mfrc522.PICC_IsNewCardPresent()) {
		return;
	}

	// Select one of the cards
	if ( ! mfrc522.PICC_ReadCardSerial()) {
		return;
	}
 dump_byte_array(mfrc522.uid.uidByte,mfrc522.uid.size);
  Serial.println(read_rfid);
	// Dump debug info about the card; PICC_HaltA() is automatically called
	//mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
  //Serial.println(read_rfid);
  if(newcard==1){
      lcd.clear();
      lcd.setCursor (0,0);
      lcd.print("Card nb ");lcd.print(read_rfid);
      lcd.setCursor (0,1);
      lcd.print("Save it?");
      ok_rfid_n=read_rfid;
  }
  if(read_rfid==ok_rfid_1){
    if(newcard==0){
      lcd.clear();
      lcd.setCursor (0,0);
      lcd.print("Card accepted");
      lcd.setCursor (0,1);
      lcd.print("Opening door!");
      open_lock();
      flashg(1,100);
    }
  }
  else{
     if(newcard==0){
      lcd.clear();
      lcd.setCursor (0,0);
      lcd.print("Card rejected");
      lcd.setCursor (0,1);
      lcd.print("not accepted");
      dont_open();
      flashr(1,100);
    }else{
      flashg(1,100);
      lcd.clear();
      lcd.setCursor (0,0);
      lcd.print("Card nb ");lcd.print(read_rfid);
      lcd.setCursor (0,1);
      lcd.print("Save it?");
      ok_rfid_n=read_rfid;
    }
  }
}

void ShowReaderDetails() {
	// Get the MFRC522 software version
	byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
	Serial.print(F("MFRC522 Software Version: 0x"));
	Serial.print(v, HEX);
	if (v == 0x91)
		Serial.print(F(" = v1.0"));
	else if (v == 0x92)
		Serial.print(F(" = v2.0"));
	else
		Serial.print(F(" (unknown)"));
	Serial.println("");
	// When 0x00 or 0xFF is returned, communication probably failed
	if ((v == 0x00) || (v == 0xFF)) {
		Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
	}
}

 

By continuing to use this site, you agree to the use of cookies to personalize content and advertisements, to provide social media functionality, to analyze our traffic using Google services like Analytics and Adsense.

Google Adsense and its partners may use your data for advertising personalization and cookies may be used for personalized and non-personalized advertising. How does Google use my data?
Please use the following button to see the list of Google partners as well as all the details regarding cookies.
See detailsI Accept
These cookies are mandatory for the operation of isn-services.com, if you do not accept them please quit this site.
You have the right to refuse cookies and leave the site or to change the parameters.