The Chameleon Bag

In developing this project, I wanted to combine RFID tag technology and RGB LEDs into a fun and delightful experience. When I decided on creating a messenger bag with a reactive front panel, I knew that it would have a very functional aspect too.

Some of my inspiration came from ET (Everything is a Toy) and the Reading Glove. Both show unique ways of using RFID tags in electronics, one for fun and one for education.

2

I worked with two strips of RGB LEDs to create a 7 by 7 LED matrix. After getting them up and running, I added in the RFID reader. Although I did not find a specific precedence combining these two elements, I did use this tutorial for the RGB LED set-up and this tutorial for the RFID code.

14

After the code was up and running, I soldered together a Boarduino for the brains of my final bag, and attached my RFID reader to it. 2405_001-1

I designed a messenger bag with extra space in the front flap and back panel to accommodate one inch-thick foam to diffuse the light and protect the electronics, respectively. I put a zipper on the back panel to allow access to the electronics and to the battery pack.

17

I also created useful pockets, an adjustable strap, and magnetic snaps to hold the LED panel in place.

20

I laser cut a front panel out of wood to hold the LEDs in place. Above is the final set up for the front flap and back panel. And below is my final bag!

IMG_5585 IMG_5592

These pictures show the final, fully functional bag. This video shows my process and end result!

See my Arduino code below the jump!

#include "SPI.h"
#include "Adafruit_WS2801.h"
#include "Adafruit_PN532.h"

#define SCK (2)
#define MOSI (3)
#define SS (4)
#define MISO (5)
int led = 13;
int dataPin = 11; // Yellow wire on Adafruit Pixels
int clockPin = 12; // Green Wire

Adafruit_PN532 nfc(SCK, MISO, MOSI, SS);

// Set the first variable to the NUMBER of pixels. 25 = 25 pixels in a row
Adafruit_WS2801 strip = Adafruit_WS2801(50, dataPin, clockPin);

//////////////////////////////////// SETUP

void setup(void) {
Serial.begin(115200);
Serial.println("Hello!");

nfc.begin();

uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Didn't find PN53x board");
while (1); // halt
}

// Got ok data, print it out!
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);

// configure board to read RFID tags
nfc.SAMConfig();

Serial.println("Waiting for an ISO14443A card");

//turn on LED strip
strip.begin();

// Update LED contents, to start they are all 'off'
strip.show();
}

/////////////////////////////////// LOOP

unsigned digit = 0;

void loop() {
boolean success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

// wait for RFID card to show up!
//Serial.println("Waiting for an ISO14443A Card ...");

// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
// 'uid' will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);

uint32_t cardidentifier = 0;

if (success) {
// Found a card!

Serial.print("Card detected #");
// turn the four byte UID of a mifare classic into a single variable #
cardidentifier = uid[3];
cardidentifier <<= 8; cardidentifier |= uid[2];
cardidentifier <<= 8; cardidentifier |= uid[1];
cardidentifier <<= 8; cardidentifier |= uid[0];
Serial.println(cardidentifier);

// repeat this for loop as many times as you have RFID cards
if (cardidentifier == 3574307259) { // tardis
gradient(50); //rainbow blue
}

if (cardidentifier == 3574370011) { //circle token (gloves)
colorWipes(Color(0, 224, 112), 50); //green

}

if (cardidentifier == 4271042990) { // sticker 1 (scarf)
colorSolid(Color(0, 224, 224), 50); //turquoise

}

if (cardidentifier == 2980480123) { // sticker 2
colorAnimation(Color(255, 0, 0), Color(0, 255, 0), 500, 10); //christmas animation
}

if (cardidentifier == 2774304574) { // key fob
rainbow(20);
//colorWipes(Color(224, 0, 0), 50);
}

if (cardidentifier == 2761822987) { // card
colorSolid(Color(0, 0, 0), 50); // turn off LEDs
}

}
}

/////////////////////////////////// HELPERS

void colorSolid(uint32_t c, uint8_t wait) {
int i;

for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
}
strip.show();
}

void colorAnimation(uint32_t c, uint32_t d, uint8_t wait, uint8_t r) {
int i;
int j;

for (j=0; j < r; j ++) {
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
}
strip.show();
delay(wait);

for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, d);
}
strip.show();
delay(wait);
}
}

void colorWipes(uint32_t c, uint8_t wait) {
int i;

for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
delay(wait);
strip.show();
}

}

//Rainbow LED Function
void gradient(uint8_t wait) {
int i, j;

for (j=150; j < 151; j++) {
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel( (i + j) % 255));

}
strip.show(); // write all the pixels out
delay(wait);
}
}

void rainbow(uint8_t wait) {
int i, j;

for (j=0; j < 256; j++) { // 3 cycles of all 256 colors in the wheel
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel( (i + j) % 255));
}
strip.show(); // write all the pixels out
delay(wait);
}
}

void rainbows(uint8_t wait) {
int i, j;

for (j=70; j < 71; j++) { // 3 cycles of all 256 colors in the wheel
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel( (i + j) % 255));
}
strip.show(); // write all the pixels out
delay(wait);
}
}

// Create a 24 bit color value from R,G,B
uint32_t Color(byte r, byte g, byte b)
{
uint32_t c;
c = r;
c <<= 8;
c |= g;
c <<= 8;
c |= b;
return c;
}

//Input a value 0 to 255 to get a color value.
//The colours are a transition r - g -b - back to r
uint32_t Wheel(byte WheelPos)
{
if (WheelPos < 85) {
return Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
About these ads