KeyDuino forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Un ├ęchange d'information autour de la carte KeyDuino
HomeHome  Latest imagesLatest images  RegisterRegister  Log inLog in  


 NFC lock GIFT box

Go down 
KeyDuino TEAM

Messages : 85
Reputation : 4
Date d'inscription : 2015-10-10
Age : 30
Localisation : Lille, FRANCE

NFC lock GIFT box  Empty
PostSubject: NFC lock GIFT box    NFC lock GIFT box  EmptySat 10 Oct - 16:49

This project is inspired by the NFC box here


 The goal of this sketch is to unlock a "giftbox" with KeyDuino and a NFC tag, via a servomotor.
 Get the ID of your tag, put it in NFC_KEY below.
 When you scan the right tag with KeyDuino, the servo will unlock the box.
 More information in the video of the project:
 Author: Mr Stein
 Revised by Raymond Borenstein - CITC-EuraRFID
 Compatible with KeyDuino 5.1
 Join to ask your questions, suggest your ideas, and show your projects!

#include <Servo.h> //Servo library is included by default, you should not need to install anything
#include <KeyDuino.h>

#define LED_PIN    13
#define SERVO_PIN  12

KeyDuino keyDuino;

uint8_t uid[] = {
  0, 0, 0, 0, 0, 0, 0 };
uint8_t uidLength;

Servo myServo;  // create servo object to control the servo

String NFC_KEY_1 = "xxxxxxxxxxxx";
String NFC_KEY_2 = "xxxxxxxxxxxx";

//Function to open the servo
void openServo() {

void setup(void) {
  Serial.println("KeyDuino BOX is ready, please scan a NFC tag");
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);

void loop(void) {
  uint8_t success;
  String readID;
  success = keyDuino.readTargetID(uid, &uidLength);
  if (success){
    readID = keyDuino.convertUintToString(uid, uidLength);

    if (readID == NFC_KEY_1 || readID == NFC_KEY_2){
      digitalWrite(LED_PIN, LOW);
      digitalWrite(LED_PIN, HIGH);
    else {;;
Back to top Go down
NFC lock GIFT box
Back to top 
Page 1 of 1
 Similar topics
» NFC drawer lock
» Entry door electronic lock

Permissions in this forum:You cannot reply to topics in this forum
KeyDuino forum :: KeyDuino projects & tutorial :: Tutorials :: Official tutorial-
Jump to: