0

WARD
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

WARD

by ziplock on Fri Feb 06, 2009 10:06 pm

The Wireless Automatic Door Opener, or WARD for short, is a project I'm working on to submit to Libelium's hacking contest. The project uses two Arduino boards, two XBee radios from Digi, my own RFIDShield with an Innovations ID-12 that I purchased from SparkFun installed, an RFID tag from Sparkfun, an Xbee board from Adafruit, and an Extender Shield and Lithium Backpack from Liquidware (Yay!). The code is split into two parts, one for each Arduino, and uses the Servo and SoftwareSerial libraries from arduino.cc
Code: Select all | TOGGLE FULL SIZE
/*
RFID Door opener
by Adam Aitoumeziane
Uses Xbee, 2 Arduinos, RFID reader, and 2 servos to unlock doors
RFID Reader code from Making Things Talk by Tom Igoe, hacked a little by me
*/


// initiate Servo and SoftSerial libraries
#include
#include


// Define pins
#define rxPin 12 // Set RX pin for Softserial
#define txPin 11 // Set TX for Softserial
#define tagLength 10 // Tag length (duh!)
#define startByte 0x02 // Adjust for Parallax if needed
#define endByte 0x03 // Adjust for Parallax if needed
#define dataRate

// Setup softserial
SoftwareSerial xbee = SoftwareSerial(rxPin, txPin);

char tagID[tagLength]; // array to hold the tag
int tagIndex = 0; // counter for number of bytes read
int tagComplete = false; // whether the whole tag's been read
char preKey[] = "0415AB6FB7";
Servo open;

void setup() {
//start softserial
xbee.begin(9600); // Start Xbee data
//start hardware serial
Serial.begin(9600); // Adjust for Parallax if needed (2400)
open.attach(9); // Attach servo
}

void loop() {
//read/parse serial data
if (Serial.available() > 0) {
readByte();
}
}

// Read bytes, put proper in tagID

void readByte() {
char thisChar = Serial.read();
switch (thisChar) {
case startByte: // start character
//reset tag index counter
tagIndex = 0;
break;
case endByte: // end char
tagComplete = true; // you have whole tag!
break;
default: // any other char
tagComplete = false; // Still more bytes!
// add byte to tagID
if (tagIndex < tagLength) {
tagID[tagIndex] = thisChar;
// increment byte counter
tagIndex++;
}
break;
}
if (tagComplete == true) {
if (preKey == tagID) {
// Reset servo, set to 0
open.write(0);
// Write servo to 45
open.write(45);
//Print data over Xbee to 2nd module
xbee.print( newKey );
}
}
}
ziplock
 
Posts: 41
Joined: Fri Jan 30, 2009 7:03 pm

Re: WARD

by adafruit on Fri Feb 06, 2009 11:04 pm

photos or it dont exist!

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: WARD

by ziplock on Sat Feb 07, 2009 12:40 am

Yeah, I know. I've got almost all of the parts, except for the RFIDShield, an RFID Tag (I forgot!), and an Xbee breakout board. They're all on their way to my domicile.
ziplock
 
Posts: 41
Joined: Fri Jan 30, 2009 7:03 pm

Re: WARD

by karlgg on Mon Feb 09, 2009 11:40 pm

Oh, no! That means you don't exist, either!

Wait, neither do I.
I think I am, therefore I am... I think.

karlgg
 
Posts: 212
Joined: Sat Dec 27, 2008 2:41 pm
Location: Anthony, NM

Please be positive and constructive with your questions and comments.