Tuesday, June 8, 2010

It supports 2 motors, backwards and forwards. Now you might ask, why did I need a motor driver? 2 reasons.

1.) The Arduino doesn't have enough current output to handle a motor without it wearing down the Arduino.2.) I need to fire the motor forwards to unlock the door and then backwards to lock it again. You do this by changing the polarity on the motor, which is done using an H-Bridge.

I originally wanted to build my own H-Bridge, but after researching it I realized it was over my head, so I bought a nice, already put together motor driver. This thing is so easy to use.

I supply it power. Set pin ENA to high to enable motor 1. Then you set IN1 to high to turn the motor one way and IN2 to high to turn it another way. That's it!

CAN'T WAIT! It's the last piece I need before I can prototype it all together. Then i'll put it all on a PCB as close as I can and solder it all together. Then i'll need to measure it and find some project boxes. More on the motor driver later!!

Friday, June 4, 2010

I got my Boarduino and put it together. It was really fun and it actually works! I also got the deadbolt in but haven't had time to take it apart and see if I can get to the motor. Also i've been looking at motor drivers, as i'm going to need one since the Boarduino can't output enough to use a motor itself.

Saturday, May 29, 2010

So I bought a schlage deadbolt. The one where you type in a number and it unlocks. It doesn't work like you think it does. The handle on the outside free spins until you put in the correct code ( or power it from an Arduino) and then you can turn the handle and unlock it. If I had used that one I would have had to scan, turn the knob then open the door. For that much work I might as well just use a key.

I found another one that I have ordered. I think the motor on this one actually locks/unlocks the door. More updates after that!

Also, I ordered a Boarduino. I think on the finished product i'm going to use that.

Wednesday, May 12, 2010

I found some already written code doing exactly what I wanted it to. It did have a bug in it that I had to get some help figuring out. ( If your RFID started with a 00 it had some issues ) Here is the code.

if ( readCard[5] == checksum ) // See if the 5th BYTE (the checksum) read in from the reader { // matches the checksum caculated checksum = 0; // If so, we can empty the variable storing the calculated checksum Serial.println(); Serial.println("Checksum correct"); Serial.println(); if ( isMaster( readCard ) ) // Check to see if the card is the master programing card { programMode = true; // If so, enable programing mode } else { if ( findID(readCard) ) // If not, see if the card is in the EEPROM { openDoor(5); // If it is, open the door lock Serial.println(); Serial.print("It's stored"); Serial.println(); } else { failed(); // If not, show that the ID was not valid Serial.println(); Serial.print("It's NOT stored"); Serial.println(); } } } else // If the checksum failed { // Print out the checksum

// If the serial port is ready and we received the STX BYTE (2) then this function is called// to get the 4 BYTE ID + 1 BYTE checksum. The ID+checksum is stored in readCard[6]// Bytes 0-4 are the 5 ID bytes, byte 5 is the checksumvoid getID(){ byte bytesread = 0; byte i = 0; byte val = 0; byte tempbyte = 0;

// Write an array to the EEPROM in the next available slotvoid writeID( byte a[] ){ if ( !findID( a ) ) // Before we write to the EEPROM, check to see if we have seen this card before! { int num = EEPROM.read(0); // Get the numer of used spaces, position 0 stores the number of ID cards /* Serial.print("Num: "); Serial.print(num); Serial.print(" \n"); */ int start = ( num * 5 ) + 1; // Figure out where the next slot starts

num++; // Increment the counter by one EEPROM.write( 0, num ); // Write the new count to the counter

// Check two arrays of bytes to see if they are exact matchesboolean checkTwo ( byte a[], byte b[] ){ //if ( a[0] != NULL ) // Make sure there is something in the array first match = true; // Assume they match at first

// Looks in the EEPROM to try to match any of the EEPROM ID's with the passed IDboolean findID( byte find[] ){ int count = EEPROM.read(0); // Read the first Byte of EEPROM that Serial.print("Count: "); // stores the number of ID's in EEPROM Serial.print(count); Serial.print("\n"); for ( int i = 1; i <= count; i++ ) // Loop once for each EEPROM entry { readID(i); // Read an ID from EEPROM, it is stored in storedCard[6] if( checkTwo( find, storedCard ) ) // Check to see if the storedCard read from EEPROM { // is the same as the find[] ID card passed Serial.print("We have a matched card!!! \n"); return true; break; // Stop looking we found it } else // If not, return false { Serial.print("No Match here.... \n"); }

// Controls LED's for Normal mode, Blue on, all others offvoid normalModeOn(){ digitalWrite(powerPin, HIGH); // Power pin ON and ready to read card digitalWrite(passPin, LOW); // Make sure Green LED is off digitalWrite(failPin, LOW); // Make sure Red LED is off digitalWrite(doorPin, LOW); // Make sure Door is Locked}

// Controls LED's for program mode, cycles through RGBvoid programModeOn(){ digitalWrite(powerPin, LOW); // Make sure blue LED is off digitalWrite(failPin, LOW); // Make sure blue LED is off digitalWrite(passPin, HIGH); // Make sure green LED is on delay(200); digitalWrite(powerPin, LOW); // Make sure blue LED is off digitalWrite(failPin, HIGH); // Make sure blue LED is on digitalWrite(passPin, LOW); // Make sure green LED is off delay(200); digitalWrite(powerPin, HIGH); // Make sure blue LED is on digitalWrite(failPin, LOW); // Make sure blue LED is off digitalWrite(passPin, LOW); // Make sure green LED is off delay(200);}

// Flashes the green LED 3 times to indicate a successful write to EEPROMvoid successWrite(){ digitalWrite(powerPin, LOW); // Make sure blue LED is off digitalWrite(failPin, LOW); // Make sure blue LED is off digitalWrite(passPin, HIGH); // Make sure green LED is on delay(200); digitalWrite(passPin, LOW); // Make sure green LED is off delay(200); digitalWrite(passPin, HIGH); // Make sure green LED is on delay(200); digitalWrite(passPin, LOW); // Make sure green LED is off delay(200); digitalWrite(passPin, HIGH); // Make sure green LED is on delay(200);}

// Flashes the red LED 3 times to indicate a failed write to EEPROMvoid failedWrite(){ digitalWrite(powerPin, LOW); // Make sure blue LED is off digitalWrite(failPin, HIGH); // Make sure red LED is on digitalWrite(passPin, LOW); // Make sure green LED is off delay(200); digitalWrite(failPin, LOW); // Make sure red LED is off delay(200); digitalWrite(failPin, HIGH); // Make sure red LED is on delay(200); digitalWrite(failPin, LOW); // Make sure red LED is off delay(200); digitalWrite(failPin, HIGH); // Make sure red LED is on delay(200);}

My first Arduino project is an RFID door unlocker for my home. Below are the obstacles I have to overcome:

1.) DONE Get the Arduino to read a tag (with an ID-20 reader) and compare it to stored tags in its EEPROM2.) DONE (bought one) Figure out how to build an H-BRIDGE3.) DONE Buy, take apart and run wires to the motor powered deadbolt4.) Solder the finished circuits to some boards5.) Install