PROXIMITY TESTS RFID:
FINAL PRESENTATION VIDEO:
FINAL PRESENTATION:
ARDUINO CODE:
#include <SPI.h>
#include <MFRC522.h>
#include <Adafruit_NeoPixel.h>
#define NUM_LEDS 6 Number of NeoPixels
#define PIN 7 DIGITAL pin # where NeoPixels are connected
#define RST_PIN 9 Pin 9 for reset of RC522
#define SS_PIN 10 Pin 10 for SS (SDA) RC522
MFRC522 mfrc522(SS_PIN, RST_PIN);
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(9600); serial communication
SPI.begin(); Bus SPI
mfrc522.PCD_Init(); MFRC522
Serial.println(“Identificación LightRunner”);
strip.begin();
strip.setBrightness(100); 100/255 brightness (about 40%)
strip.show(); Initialize all pixels to 'off'
}
byte ActualUID[4]; to save tag code
byte Usuario1[4]= {0xAB, 0x00, 0x17, 0xA3} ; user 1 code AB 00 17 A3
byte Usuario2[4]= {0x64, 0x62, 0x15, 0xA0} ; user 2 code 64 62 15 A0
void loop() {
if ( mfrc522.PICC_IsNewCardPresent())
{\\
//to select a card\\
if ( mfrc522.PICC_ReadCardSerial())\\
{\\
Serial.print(F("Card UID:"));\\
for (byte i = 0; i < mfrc522.uid.size; i++) {\\
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");\\
Serial.print(mfrc522.uid.uidByte[i], HEX);\\
ActualUID[i]=mfrc522.uid.uidByte[i];\\
}\\
Serial.print(" ");\\
//comparation of UID to switch on, swith off or make another different kind of sequence\\
if(compareArray(ActualUID,Usuario1))\\
{\\
for(int j=0; j<256; j++) {\\
for(int i=0; i<NUM_LEDS; i++) {\\
strip.setPixelColor(i, Wheel((i * 16 + j) & 255));\\
}\\
strip.show();\\
delay(20);\\
}\\
}\\
else if(compareArray(ActualUID,Usuario2))\\
{\\
for(int j=0; j<256; j++) {\\
for(int i=0; i<NUM_LEDS; i++) {\\
strip.setPixelColor(i, Wheel((i * 16 + j) & 255));\\
}\\
strip.show();\\
delay(20);\\
}\\
}\\
\\
\\
else{\\
\\
for(int j=0; j<256; j++) {\\
for(int i=0; i<NUM_LEDS; i++) {\\
strip.setPixelColor(i, Wheel((i * 8 + j) & 055));\\
}\\
strip.show();\\
delay(20);\\
}
// to switch off the leds\\
for(int j=0; j<256; j++) {\\
for(int i=0; i<NUM_LEDS; i++) {\\
strip.setPixelColor(i, 0);\\
}\\
strip.show();\\
delay(20);\\
}\\
\\
\\
}\\
\\
mfrc522.PICC_HaltA();\\
}
}
}
uint32_t Wheel(byte WheelPos) {
if(WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);\\
} else if(WheelPos < 170) {
WheelPos -= 85;\\ return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);\\
} else {
WheelPos -= 170;\\ return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);\\
}
}
boolean compareArray(byte array1[],byte array2[])
{
if(array1[0] != array2[0])return(false);
if(array1[1] != array2[1])return(false);
if(array1[2] != array2[2])return(false);
if(array1[3] != array2[3])return(false);
return(true);
}