Search icon CANCEL
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arduino Wearable Projects

You're reading from  Arduino Wearable Projects

Product type Book
Published in Aug 2015
Publisher
ISBN-13 9781785283307
Pages 218 pages
Edition 1st Edition
Languages

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $19.99/month. Cancel anytime}