Book Image

Arduino Wearable Projects

Book Image

Arduino Wearable Projects

Overview of this book

Table of Contents (16 chapters)

The final code


The following sketch is basically a combination of the three previous sketch examples in this chapter. First, it will activate the NFC shield and look for a tag or card. If the right card or tag is registered, this will activate the motor, which will turn the look and then the door will be open. The door will be open for 20 seconds and then the motor will turn back again locking the door. The code should work as supposed to, but the construction might need some tinkering before everything lines up as it should. Once everything is in place, it's time to upload the final code, which you will find here:

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#include <Servo.h>

// Define the I2C pins
#define PN532_IRQ   (2)
#define PN532_RESET (3)  // Not connected by default on the NFC Shield
//Connect the shield I2C connection:
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
//Create servo object
Servo myservo;


void setup(void) {
  Serial.begin(115200...