Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Arduino Wearable Projects

You're reading from   Arduino Wearable Projects Design, code, and build exciting wearable projects using Arduino tools

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher
ISBN-13 9781785283307
Length 218 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Tony Effe A Olsson Tony Effe A Olsson
Author Profile Icon Tony Effe A Olsson
Tony Effe A Olsson
Arrow right icon
View More author details
Toc

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 $19.99/month. Cancel anytime