Project showcase
Access RFID with Light Feedback

Access RFID with Light Feedback © GPL3+

A fun project where you get colorful blinks depending on the RFID ID.

  • 2,584 views
  • 1 comment
  • 6 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
This is the base chipset I used to make this project.
×1
1586 00
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
Ring with 24 pixels, see: https://www.adafruit.com/product/1586
×1
12002 04
Breadboard (generic)
×1
11026 02
Jumper wires (generic)
Connected them between breadboard and components. See Schematics further down.
×11
Adafruit industries ada62 image 75px
USB-A to B Cable
To power and upload code to Arduino UNO
×1
RFID Module (Generic)
MFRC522 / RFID-RC522 chipset. https://playground.arduino.cc/Learning/MFRC522
×1

Necessary tools and machines

09507 01
Soldering iron (generic)
I had to solder the RFID-RC522 to make sure it had 100 % connection.

Apps and online services

Ide web
Arduino IDE
I programmed and connected using the IDE software.

About this project

Arduino Uno, MFRC522 RFID scanner & NeoPixel24

So I recently bought my first Arduino because I got curious about RFID technology, or rather inspired! So I ended up purchasing different components and expanding when I discovered the cool Adafruit NeoPixel ring with 24 pixels.

From there on, I made a few code projects where I first tried and failed some with the MFRC522 scanner, so I ended up soldering it to make sure it had full connection, which worked!

So what I did was experimenting with each component to see how I could set them all together into one project. There were a lot of failing, testing of resistors for the NeoPixel and such. I ended up using .setBrightness instead of using extras. This way I felt I used less dangerously high power consumption for the ring.

In short terms, I wanted to make a visual feedback for when you scan an RFID chip. It blinks red four times for wrong card, and blinks green 10 times for the right card(s).

See video on Twitter: https://twitter.com/WerzyKittyDrake/status/948308164822360064

Code

Arduino Uno CodeArduino
The complete code
#include <Adafruit_NeoPixel.h>
#include <require_cpp11.h>
#include <deprecated.h>
#include <MFRC522.h>
#include <MFRC522Hack.h>
#include <MFRC522Extended.h>
#include <MFRC522Debug.h>
#include "SPI.h"

// Setup of configurations
const int      delayval  =  50; // Time each pixel pauses to do it's duty.
const int      PIN       =  6; // Data output to Adafruit NeoPixel
const int      NUMPIXELS =  24; // Number of pixels in the ring ^
const int      SS_PIN    =  10; // Data PIN for MFRC522
const int      RST_PIN   =  9; // Reset PIN for MFRC522
const int      TIME      =  150; // Time between each NeoPixel blink.

// Defining needed variables for the NeoPixel: pixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// Defining colors
const uint32_t red       =  pixels.Color(255, 0, 0);
const uint32_t green     =  pixels.Color(0, 255, 0);
const uint32_t yellow    =  pixels.Color(255, 255, 0);
const uint32_t blank     =  pixels.Color(0, 0, 0);

MFRC522 rfid(SS_PIN, RST_PIN); // Prepares PINS
MFRC522::MIFARE_Key key;

/**
 * Function setup:
 * Desc:  Main function for Arduino programming language.
 * Extra: It runs only once during startup of the script.
 */
void setup() {
  Serial.begin(9600);
  Serial.println("Starting all...\n\n");
  pixels.begin();
  pixels.setBrightness(20); // This is to make sure the lights won't burn up.
  SPI.begin(); // Make the NeoPixel and microcontroller communicate
  rfid.PCD_Init(); 
}

/**
 * Function loop:
 * Desc:  Runs over and over, hence loop.
 */
void loop() {
  setAll(yellow); // Sets initial color of the NeoPixel ring to yellow.
  
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()){
    return;
  }
  MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
  if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI &&
      piccType != MFRC522::PICC_TYPE_MIFARE_1K &&
      piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
    Serial.println(F("Your tag is not of type MIFARE Classic."));
    return;
  }
  String strID = "";
  for (byte i = 0; i < 4; i++) {
    strID +=
      (rfid.uid.uidByte[i] < 0x10 ? "0" : "") +
      String(rfid.uid.uidByte[i], HEX) +
      (i != 3 ? ":" : "");
  }
  strID.toUpperCase();
  
  if (validateCard(strID)) {
    Serial.println("*** Access granted! ***");
    Serial.print("*** The source was just accessed by a card with this ID: ");
    Serial.println(strID);
    Serial.print("");
    for(int i=0;i<10;i++){ // Repeat ten times, total of 1.5 seconds excluding light time change.
      setAll(green);
      delay(TIME);
      setAll(blank);
      delay(TIME);
    }
    return;
  }
  else {
    Serial.println("*** Access denied! ***");
    Serial.print("*** You tried a card with this id: ");
    Serial.println(strID);
    Serial.println("");
    for(int i=0;i<4;i++){ // Repeat only four times to avoid using too much time, total of 600ms.
      setAll(red);
      delay(TIME);
      setAll(blank);
      delay(TIME);
    }
    return;
  }
}

/**
 * Function setAll:
 * Desc: Sets all pixels as defined in
 * configuration
 */
void setAll(uint32_t color) {
  for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, color);
    pixels.show();
  }
}

/**
 * Function validateCard:
 * Desc: Checks ID of card and returns if the
 * right card was scanned.
 */
bool validateCard(String usercard) {
  // Insert your own card ID's here, insert more with else if under
  if(usercard.indexOf("AA:BB:CC:DD") >= 0) {
    return true;
  }
  else if(usercard.indexOf("AA:BB:CC:DD") >= 0) {
    return true;
  }
  else return false;
}

Schematics

Image Schematics
A plain PNG picture of the connections
Colorrfidscan bb vxysvewgkh
Fritzing Schematics
Open in Fritzing (http://fritzing.org/download/) to see schematics in several views.
colorrfidscan_d4yGH7Hmqf.fzz

Comments

Author

Werzaire
Werzaire
  • 1 project
  • 1 follower

Additional contributors

  • Partial code and connection of mfrc522 by Matthew

Published on

January 3, 2018

Members who respect this project

10891948 10205570895421414 8572839175924528019 nAdambenzCnyn noo6fluiip

and 3 others

See similar projects
you might like

Similar projects you might like

Security System And Access Control With Arduino And RFID

Project tutorial by Sarath P

  • 10,282 views
  • 1 comment
  • 22 respects

Security Access Using RFID Reader

by Aritro Mukherjee

  • 329,220 views
  • 58 comments
  • 364 respects

RFID Door Access Control with Counter

Project tutorial by sarful

  • 5,276 views
  • 0 comments
  • 15 respects

RFID Based Automatic Door System

Project showcase by Robodia Technology

  • 50,036 views
  • 24 comments
  • 129 respects

Arduino RFID Keycard Access

Project tutorial by Brian Carbonette

  • 14,426 views
  • 1 comment
  • 26 respects

Arduino Powered CPR Feedback Device

Project showcase by David Escobar

  • 5,875 views
  • 9 comments
  • 28 respects
Add projectSign up / Login