I have been thinking and experimenting really hard lately. I’ve bee trying to figure out exactly which on of the 500 projects I want to debark on. There are just so many in my mind but I do believe I want a project that will put all of my skills (so far acquired) to the test.

So I’ve decided the best way to test everything from programming, sensors, wireless communicatings, etc should end in Home Automation.

First let me start by mentioning who I am when it comes to getting up and getting stuff done. I’m horrible. I mean really bad. I can go to bed early and still sleep past the ‘alarm’. BTW, we are talking like 10-12 hours of sleep here. The messed up thing is that I can’t control it.

This started my endeavor to create a complete system with micro-devices to enable my life to be much easier. I want to automate everything. Imagine this:

Before you even wake up in the morning, a small device sets a cascade of events in motion. It has a few jobs to do before you even open your eyes. It starts by opening the blinds. As we all know sun light wakes up the brain due to our pituitary gland. The first function ensures that our brains notice that it is morning.

Yes for most people, they already get it. But what about those night howls? The people that would easily sleep till noon if they could?

Well after openning the blinds, things get interesting. A motion sensor monitors the bedroom. If there is no motion after a certain amount of time, an audible alarm sounds. This could be anything from a tone, radio, or MP3 playlist that assists in the wake up process.

In the meantime, a symphony of events are already in motion elsewhere in the house. The cofee maker turns on to brew that precious cup of coffee you need when you first wake up. The shower in your bathroom comes to life and warms up quickly so after you take those few sips you can get read for the day. After you exit the shower, the stove/oven/microwave heats up breakfast for you ensuring that its ready and just right when you are done getting ready.

Meanwhile, all of the lights in your house are set up on sensors to ensure you don’t run up your electric bill. The system is even smart enough to ensure you are as GREEN as possible. The same is true for your TV. After all, who doesn’t want to watch the morning news while they eat their breakfast. The biggest problem with your TV and stereo amp is that they waist power when they are turned off. Why not have the system activate them when you’re ready?

The best part about your home automation system is that it controls itself. It knows when you pull the tasty breakfast/lunch/dinner off of the stove or out of the oven. It knows to power down when your done. The system even controls your heating and air conditioning system. Detecting when you’re home to ensure the temperature you want is always running when you enter and when you stay home. As soon as you leave, it knows to save some energy so you aren’t taxed by TXU next month.

My Idea
There are so many simple devices in your house. So many things a tiny device can control. Imagine taking each of these commonly used devices and integrating them in a wireless network. This would allow a computer or smaller device to control exactly what you want.

Imagine locking the door to your house. That even would trigger a serious of events that would occur which would ensure that you house is protected. Not just from intruders, not just from smoke and fire, but to the extint that you can rest assured that your oven is really off…Even if you forgot to turn the knob.

That is the power of the cheap microcontroller. That is my goal!

I am looking to do something that you have read about….that you have heard about. A cheap way to control every light switch, every power switch, every function in your home that makes you productive. The best part about it is you can Go Green. Something that will save you and the environment a lot of wasted resources and dollars.

Lets face it…if we actually did Go Green we would cut our Electric bill in half. Something that would make all of us happy in this world. On top of it, we would significantly reduce our footprint in todays world.

The Solution
…Is automation. That’s all we’re missing. We can control so much in todays world; the problem is we do not take advantage of it. Therefore, I set out now to fix two problems:

a) I want to ensure I get up every morning. I want to ensure that getting ready is as fast as possible so I can get a jump on the morning. I want to ensure that everything is ready when I am ready to use it and that its off when I don’t.

b) I want to reduce my foot print. I’m tired of everything in my house using power when I’m not home. Hell, lets just say for a moment that you don’t care about global warming. Do you realize that if everything plugged into your house was actually unplugged that you would save 20-25% on electricity per month?

Multiply that by smart decisions by a programmed controller when it comes to the heating and A/C and a lot of other factors and you would easily pay for a small setup in an apartment easily in 3 months (via energy savings alone). The benefits are just to great to ignore.

My Project
This is what I am working on and I need as much help as possible. I know, together, we can pull this off. Just by my small experiements alone; I know its possible. I want to automate everything. Bring it down to a sensor level. Yes, it could be your mobile phone that triggers something. It could be something else. The point is, why no reduce your energy bill, pay for the setup, and still get a way with murder.

That is my goal. I will find a way.

I need help so if you’re interested, call me. I need developers, EEs, testing personnel, and clients. Yes I said clients. They can help get what I see as an open source solution off the ground. We need to take action now!

del.icio.us:Home Automation = Arduino + Xbee + Make Controller digg:Home Automation = Arduino + Xbee + Make Controller spurl:Home Automation = Arduino + Xbee + Make Controller wists:Home Automation = Arduino + Xbee + Make Controller simpy:Home Automation = Arduino + Xbee + Make Controller newsvine:Home Automation = Arduino + Xbee + Make Controller blinklist:Home Automation = Arduino + Xbee + Make Controller furl:Home Automation = Arduino + Xbee + Make Controller reddit:Home Automation = Arduino + Xbee + Make Controller fark:Home Automation = Arduino + Xbee + Make Controller blogmarks:Home Automation = Arduino + Xbee + Make Controller Y!:Home Automation = Arduino + Xbee + Make Controller smarking:Home Automation = Arduino + Xbee + Make Controller magnolia:Home Automation = Arduino + Xbee + Make Controller segnalo:Home Automation = Arduino + Xbee + Make Controller

Issues with Xbee

Sometimes technology can make you really want to bang your head against the proverbial brick wall. I’m definitely feeling that today as I spent quite a bit of time attempting to get two Xbee modules to communicate. Here is my setup. I have one Xbee controller plugged into my Make Controller and another plugged into a breadboard. The Make Controller is currently powering both Xbee modules at 3.3V. I am attempting to get these two modules to communicate but have had no such luck.

Here is a picture of my current setup.
Xbee Communication Issue with Make Controller

In the above picture the standalone Xbee is using the Make Controller’s Xbee power to operate. The potentiometer in this picture is currently disconnected from the transmitting Xbee. The other Xbee breakout board is also pictured.

1) I programmed both Xbee modules with the xctu.bin and X-CTU application via the Make Controller and Maxstream’s software. I ensured the following:
    a) The channel was set to ‘C’ or 12.
    b) The PANID was set to 550.
    c) All other settings were unchanged and the same.
    d) The firmware used was 10A5.
2) I programmed one Xbee module to read a potentiometer. This Xbee module is on a breakout board connected to a breadboard. The potentiometer is connected to AD0. I also have two LEDs connected to the ON pin and Assoc pin. The ON LED lights up solid and the Assoc blinks every second or so.
3) Vcc and GND on the breadboarded Xbee are borrowing power form the Make Controller’s Xbee
4) The Make Controller has the Xbee board from MakingThings.com plugged into the Serial connection on the Make Controller board. I have also connected an LED from the Assoc pin to ground and this LED also blinks every second or so.
5) The standalone Xbee has been configured to send data from the potentiometer according to this link.
6) The Xbee module connected to the Make Controller board has been programmed to receive data via the same link.
7) The only command that will respond from the Make Controller’s Xbee is the /xbeeconfig/active command. The Xbee on the Make Controller will not report its Address, PanID, Channel, or the status of the potentiometer at AD0.
8 ) The only thing that does not work properly in the X-CTU application is the range test. It reports "Timeout waiting for data". I believe this is due to the Xbee modules not connecting/syncing up.

So as mentioned, I am banging my head against the brick wall at this point trying to get these to work. More details of what might be wrong can be found at the MakingThings forum here.

Hopefully I can get this issue resolved quickly as they are needed for my current project.

del.icio.us:Issues with Xbee digg:Issues with Xbee spurl:Issues with Xbee wists:Issues with Xbee simpy:Issues with Xbee newsvine:Issues with Xbee blinklist:Issues with Xbee furl:Issues with Xbee reddit:Issues with Xbee fark:Issues with Xbee blogmarks:Issues with Xbee Y!:Issues with Xbee smarking:Issues with Xbee magnolia:Issues with Xbee segnalo:Issues with Xbee

I just received an inexpensive keypad from SparkFun the other day and have attempted to hook it up with no such luck yet. I’m hoping I am just being stupid about the whole thing. I grabbed the Keypad Library from the Arduino Playground and set the correct pins according to the Arduino tutorial. No such luck.

So I started doing a little research and realized real quick that the only thing SparkFun provided was an image of the circuit board and code for a PIC controller which may or may not be the right diagram of the keypad.

So I started really studying the picture provided of the board and started adding up the numbers and ended up connecting the Arduino pins to pin numbers on the keypad that would corresponded with the graphic.

Here is the keypad.
SparkFun 12 Button Keypad

I am still working on this. For now, up to the minute discussion can be found on the Arduino Forum.

del.icio.us:Biggest Headache: SparkFun 4x3 Keypad digg:Biggest Headache: SparkFun 4x3 Keypad spurl:Biggest Headache: SparkFun 4x3 Keypad wists:Biggest Headache: SparkFun 4x3 Keypad simpy:Biggest Headache: SparkFun 4x3 Keypad newsvine:Biggest Headache: SparkFun 4x3 Keypad blinklist:Biggest Headache: SparkFun 4x3 Keypad furl:Biggest Headache: SparkFun 4x3 Keypad reddit:Biggest Headache: SparkFun 4x3 Keypad fark:Biggest Headache: SparkFun 4x3 Keypad blogmarks:Biggest Headache: SparkFun 4x3 Keypad Y!:Biggest Headache: SparkFun 4x3 Keypad smarking:Biggest Headache: SparkFun 4x3 Keypad magnolia:Biggest Headache: SparkFun 4x3 Keypad segnalo:Biggest Headache: SparkFun 4x3 Keypad

I always love receiving the next device I plan to experiment with. Its so exciting opening up the packages! Its like Christmas or something.

Anyway, enough of that. I got two Xbee modules in this week. I decided to go with the regular Xbee modules because I’m just playing for now. I’m sure I’ll order the Pro modules one of these days as I come up with new ideas for my little microcontroller buddies.

I also ordered an Arduino Xbee shield from NKCElectronics which I found very reasonably priced plus had great customer service. I can’t say the same price wise on SparkFun. Plus an Xbee board from MakingThings for the Make Controller and two Xbee breakout boards from SparkFun.

Fun fun fun! Here is a pic.

Xbee Modules, Xbee Arduino Shield, MakingThings Shield, and Breakout Boards

Now I need to play with them this weekend. I might have a lot of time since I’m under the weather with some cold. Of course I’ll update TekCrack as I make headway.

del.icio.us:Catch Up: Xbee Modules for Arduino and Make Controller digg:Catch Up: Xbee Modules for Arduino and Make Controller spurl:Catch Up: Xbee Modules for Arduino and Make Controller wists:Catch Up: Xbee Modules for Arduino and Make Controller simpy:Catch Up: Xbee Modules for Arduino and Make Controller newsvine:Catch Up: Xbee Modules for Arduino and Make Controller blinklist:Catch Up: Xbee Modules for Arduino and Make Controller furl:Catch Up: Xbee Modules for Arduino and Make Controller reddit:Catch Up: Xbee Modules for Arduino and Make Controller fark:Catch Up: Xbee Modules for Arduino and Make Controller blogmarks:Catch Up: Xbee Modules for Arduino and Make Controller Y!:Catch Up: Xbee Modules for Arduino and Make Controller smarking:Catch Up: Xbee Modules for Arduino and Make Controller magnolia:Catch Up: Xbee Modules for Arduino and Make Controller segnalo:Catch Up: Xbee Modules for Arduino and Make Controller

Well, the new LCD4×40Bit-ShiftReg library is working quite well. I’m actually thinking about changing the actual name of the library but figure the above is too long. Maybe I should try something like LCD3Wire4×40 or something. Your thought are greatly appreciated!

So anyway, I added my Parallax RFID card to the setup and finally worked out the bug I was initially having with the code. For some reason the RFID code would freeze and not continue looping the loop(). I found out finally after trying everything like an idiot that I had the wrong setup for the initialization of attachInterrupt().  Apparently I had the mode set wrong to CHANGE and I should have had it set to LOW. Makes since now that I think about it. CHANGE would make it continue to go into the interrupt function over and over again. As soon as I changed the mode to LOW everything came together quickly.

So here are some pictures of the RFID + Arduino + Shift Register + LCD setup.

Arduino + Purdy LCD + Shift Register + Parallax RFID Reader Setup

Here is the ‘authorized card’ being read.

Credit card style RFID card being read by Parallax RFID reader (Authorized)
Response for authorized tag on LCD screen.
LCD response after reading a valid RFID card.

Reading an unauthorized card.
RFID reader reading an unauthorized card.

Response on LCD from unauthorized card.
LCD response to an unauthroized RFID tag.

Well there you have it. Now for the source code.

// Parallax-RFID-LCDShiftReg-0.0.2 RFID reader for Arduino with LCD output
// Wiring version by BARRAGAN <http://people.interaction-ivrea.it/h.barragan>
// Modified for Arudino by djmatic
// And pieces from Arduino Playground <http://www.arduino.cc/playground/Learning/PRFID>
// And then modified again by thekidd <http://www.tekcrack.com/category/rfid>
// 25.04.2008 - Added modified LCD4×40Bit-ShiftReg connection to display RFID results.
//              Fixed attachInterrupt lockup problem. Was set to CHANGE mode. Now set to LOW mode.
// 12.04.2008 - Added interrupt to ensure program does not hang on RFID reader.

#include <avr/interrupt.h>
#include <SoftwareSerial.h>
#include <LCD4Bit.h>

#define rxPin 2
#define txPin 3
#define ledPin 13

// LCD Variables
int lcdLines = 4;    // number of lines in your display
int doutPin = 11;    // Dout pin
int strPin = 12;     // Strobe pin
int clkPin = 10;     // Clock pin

// RFID Variables
int  val = 0;
int bytesread = 0;
char code[10];
int flag = 0;
int granted = 0;

// setup construct for lcd
LCD4Bit lcd = LCD4Bit(lcdLines, doutPin, strPin, clkPin);

// set up a soft serial port
SoftwareSerial mySerial(rxPin, txPin);

void setup() {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);    // Set rxPin as INPUT to accept SOUT from RFID pin
  pinMode(txPin, OUTPUT);   // Set txPin as OUTPUT to connect it to the RFID /ENABLE pin
  pinMode(ledPin, OUTPUT);  // Let the user know whats up

  // set the data rate for the serial ports
  mySerial.begin(2400);    // RFID reader SOUT pin connected to Serial RX pin at 2400bps

  lcd.init();         // initialize lcd
  lcd.cursorTo(1,0);  // select first display controller, line 1 & 2
  lcd.clear();        // clear lines 1 & 2
  lcd.cursorTo(3,0);  // select second display controller, line 3 & 4
  lcd.clear();        // clear lines 3 & 4
 
  delay(100);

  defaultMsg();

  attachInterrupt(0, readRFID, LOW); // Setup interrupt for SOUT on RFID reader
  digitalWrite(txPin, LOW);           // Activate the RFID reader
}

void loop() {
  // Do Something

  goRFID(); 
}

void goRFID() {
  if (flag == 1) {
    delay(1000);
    lcd.cursorTo(1,0);
    lcd.clear();
    lcd.printIn("Welcome to DCA.");
    lcd.cursorTo(2,0);
    lcd.printIn("TAG code is: ");  // possibly a good TAG
    lcd.printIn(code);           // print the TAG code
    validateRFID(code);             // Determine if right tag used. */
    flag = 0;
    delay(5000);
    digitalWrite(txPin, LOW);           // Activate the RFID reader
    defaultMsg();
  } else {
    delay(1000);
    digitalWrite(txPin, LOW);           // Activate the RFID reader
    defaultMsg();
  }
}
   

void readRFID() {
  digitalWrite(ledPin, LOW);          // Turn off debug LED - Event triggered!
  if((val = mySerial.read()) == 10) { // check for header
    bytesread = 0;

    while(bytesread<10) {             // read 10 digit code
      val = mySerial.read();

      if((val == 10)||(val == 13)) {  // if header or stop bytes before the 10 digit reading
        break;                        // stop reading
      }

      code[bytesread] = val;          // add the digit          
      bytesread++;                    // ready to read next digit 
    }

    if(bytesread == 10) {             // If 10 digit read is complete
      digitalWrite(txPin, HIGH);      // deactivate RFID reader
      digitalWrite(ledPin, HIGH);     // activate LED to show an RFID card was read
      flag = 1;
    }

    bytesread = 0;
  }
}

void validateRFID(char* i) {
  if( strncmp(i,"0F0302A114", 10) == 0) {
    // if 10 digit code equals "0F0302A114"
    digitalWrite(ledPin, HIGH); 
    lcd.cursorTo(3,0);
    lcd.clear();
    lcd.printIn("Tag matches…Access Granted!");
    lcd.cursorTo(4,0);
    lcd.printIn("Firing squad avoided!");
    digitalWrite(ledPin, LOW);
  } else {
    lcd.cursorTo(3,0);
    lcd.clear();
    lcd.printIn("Tag Failed…Access Denied!");
    lcd.cursorTo(4,0);
    lcd.printIn("Firing squad deployed!");
    digitalWrite(ledPin, LOW);
  }
}

void defaultMsg() {
  // say something
  lcd.cursorTo(1,0);
  lcd.printIn("Welcome to DCA Corp.");
  lcd.cursorTo(2,0);
  lcd.printIn("Please swipe your access card.");
  lcd.cursorTo(3,0);
  lcd.printIn("* Unauthorized access is prohibitted *");
  lcd.cursorTo(4,0);
  lcd.printIn("** Disobedience meets firing squad! **");
}

You can also download the sketch file here.

Hope this is helpful.

del.icio.us:Arduino + LCD w/Shift + Parallax RFID digg:Arduino + LCD w/Shift + Parallax RFID spurl:Arduino + LCD w/Shift + Parallax RFID wists:Arduino + LCD w/Shift + Parallax RFID simpy:Arduino + LCD w/Shift + Parallax RFID newsvine:Arduino + LCD w/Shift + Parallax RFID blinklist:Arduino + LCD w/Shift + Parallax RFID furl:Arduino + LCD w/Shift + Parallax RFID reddit:Arduino + LCD w/Shift + Parallax RFID fark:Arduino + LCD w/Shift + Parallax RFID blogmarks:Arduino + LCD w/Shift + Parallax RFID Y!:Arduino + LCD w/Shift + Parallax RFID smarking:Arduino + LCD w/Shift + Parallax RFID magnolia:Arduino + LCD w/Shift + Parallax RFID segnalo:Arduino + LCD w/Shift + Parallax RFID

Well I have finally finished the update to the original LCD4Bit library I have been hacking to bits. I’ve changed the code so that it now supports the 4×40 LCD with a NXP 74HC595N shift register. I had a hell of a time getting it all to work together and ended up having to setup the shift register with LEDs to determine what pins were doing what.

Anyway, after I got the LEDs working right I was able to send data to the first two lines of the LCD and then managed to get the code changed to allow the second Enable IC pin to work. So now I got it all up and running as it was before with the v0.1 library. The best part, I’m only using 3 pins now on the Arduino which is great for my project with everything I plan on hooking up.

Here are a few pics of the setup. Sorry for the messy wires.

Arduino + Purdy LCD + 74HC595N Shift Register

Arduino + Purdy LCD + 74HC595N Shift Register (close up)

You can get the modified library here.

Schematics are here.

Change Log
———-
v0.2 - 25/Apr/2008
* Modded code to enable a 4×40 parallel LCD screen to work through a shift register.
* Cleaned up the code a lot

v0.1 - 13/Apr/2008
* Cleaned up the code
* Enabled programmer to pass pin and other variable settings through the constructor.
* Tested with a Purdy AND791GST-LED 4×40 LCD screen
* Added rightScroll function
* Added number printing functions

I believe I will go update the LCD driver now in the RFID sketch.

del.icio.us:Arduino + Purdy LCD + 74HC595N Shift Register digg:Arduino + Purdy LCD + 74HC595N Shift Register spurl:Arduino + Purdy LCD + 74HC595N Shift Register wists:Arduino + Purdy LCD + 74HC595N Shift Register simpy:Arduino + Purdy LCD + 74HC595N Shift Register newsvine:Arduino + Purdy LCD + 74HC595N Shift Register blinklist:Arduino + Purdy LCD + 74HC595N Shift Register furl:Arduino + Purdy LCD + 74HC595N Shift Register reddit:Arduino + Purdy LCD + 74HC595N Shift Register fark:Arduino + Purdy LCD + 74HC595N Shift Register blogmarks:Arduino + Purdy LCD + 74HC595N Shift Register Y!:Arduino + Purdy LCD + 74HC595N Shift Register smarking:Arduino + Purdy LCD + 74HC595N Shift Register magnolia:Arduino + Purdy LCD + 74HC595N Shift Register segnalo:Arduino + Purdy LCD + 74HC595N Shift Register

Make Controller

Well, I just got the Make Controller in the mail this week and am excited to start playing. I managed to get it hooked up correctly after I flashed the controller with new firmware (did not work out of the box). I’ve also been working on interfacing it via OCD with C#. I can’t wait to start really playing with it. Especially since it offers Ethernet connectivity and a web server. I can only imagine what kewl things I can do with it.

One thing that does scare me though at this point is that the community is still small. I’m sure this will change as time goes on, but I have found info and support a bit more difficult to obtain. Either way, it offers a look of kewl features and as I become more knowledge about microcontrollers, I’m sure I’ll have a lot of fun with it and help the community.

Now to hacking!

del.icio.us:Make Controller digg:Make Controller spurl:Make Controller wists:Make Controller simpy:Make Controller newsvine:Make Controller blinklist:Make Controller furl:Make Controller reddit:Make Controller fark:Make Controller blogmarks:Make Controller Y!:Make Controller smarking:Make Controller magnolia:Make Controller segnalo:Make Controller

So I got a reply for John Ryan on the Arduino forums and he mentioned that I would need to use an interrupt to grab RFID data to ensure it did not stop my program while waiting for a tag. I banged my head around with the implementation of interrupt code but found a solution that seems to work quite well on the forum.

Come to find out, there is an easy function already included called attachInterrupt(). Went ahead and added this to my code and rearranged everything to allow proper operation. Here is what I got out of it:

// RFID reader for Arduino
// Wiring version by BARRAGAN <http://people.interaction-ivrea.it/h.barragan>
// Modified for Arudino by djmatic
// And pieces from Arduino Playground <http://www.arduino.cc/playground/Learning/PRFID>
// And then modified again by thekidd
// 12.04.2008 - Added interrupt to ensure program does not hang on RFID reader.

#include <avr/interrupt.h>
#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3
#define ledPin 13

// set up a soft serial port
SoftwareSerial mySerial(rxPin, txPin);

int  val = 0;
char code[10];
int bytesread = 0;

void setup() {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);    // Set rxPin as INPUT to accept SOUT from RFID pin
  pinMode(txPin, OUTPUT);   // Set txPin as OUTPUT to connect it to the RFID /ENABLE pin
  pinMode(ledPin, OUTPUT);  // Let the user know whats up

  // set the data rate for the serial ports
  mySerial.begin(2400);    // RFID reader SOUT pin connected to Serial RX pin at 2400bps
  Serial.begin(9600);      // Serial feedback for debugging in Wiring

  // say something
  Serial.println("Hello World!");
 
  attachInterrupt(0, readRFID, CHANGE); // Setup interrupt for SOUT on RFID reader
  digitalWrite(txPin, LOW);           // Activate the RFID reader
}

void loop() {
  // Do Something
}

void readRFID() {
  digitalWrite(ledPin, LOW);          // Turn off debug LED - Event triggered!
  if((val = mySerial.read()) == 10) { // check for header
    bytesread = 0;
   
    while(bytesread<10) {             // read 10 digit code
      val = mySerial.read();
     
      if((val == 10)||(val == 13)) {  // if header or stop bytes before the 10 digit reading
        break;                        // stop reading
      }
     
      code[bytesread] = val;          // add the digit          
      bytesread++;                    // ready to read next digit 
    }
   
    if(bytesread == 10) {             // If 10 digit read is complete
      digitalWrite(txPin, HIGH);      // deactivate RFID reader
      digitalWrite(ledPin, HIGH);     // activate LED to show an RFID card was read
      Serial.print("TAG code is: ");  // possibly a good TAG
      Serial.println(code);           // print the TAG code
    }
   
    bytesread = 0;
    digitalWrite(txPin, LOW);           // Activate the RFID reader
  }
}

Now that I got that working properly, I’m off to get my LCD set back up and add that code to the code above!

del.icio.us:Parallax RFID Reader + Arduino - Code w/Interrupt digg:Parallax RFID Reader + Arduino - Code w/Interrupt spurl:Parallax RFID Reader + Arduino - Code w/Interrupt wists:Parallax RFID Reader + Arduino - Code w/Interrupt simpy:Parallax RFID Reader + Arduino - Code w/Interrupt newsvine:Parallax RFID Reader + Arduino - Code w/Interrupt blinklist:Parallax RFID Reader + Arduino - Code w/Interrupt furl:Parallax RFID Reader + Arduino - Code w/Interrupt reddit:Parallax RFID Reader + Arduino - Code w/Interrupt fark:Parallax RFID Reader + Arduino - Code w/Interrupt blogmarks:Parallax RFID Reader + Arduino - Code w/Interrupt Y!:Parallax RFID Reader + Arduino - Code w/Interrupt smarking:Parallax RFID Reader + Arduino - Code w/Interrupt magnolia:Parallax RFID Reader + Arduino - Code w/Interrupt segnalo:Parallax RFID Reader + Arduino - Code w/Interrupt

So I managed to grab a Purdy LCD sample (thanks to LadyAda’s page) to test Arduino interfacing. The first problem I ran into was that my LCD has two LCD controllers (KS0066 - based on HD44780). Thankfully lega7 faced this issue and modified code to work with a 4 line LCD.

I started with that but decided I wanted to modify his library to provide a few different advantages for my design. First of all, I set it up so the developer could pass the library all of the pins and other variables depending on their specific LCD. I also added a few additional functions including an easy debug function, right scroll function, and number functions.

A lot of this is still under testing so I will update this post as I improve the library and learn more about C/C++/C#. Hopefully it will work with other screens easily. This I have not tested yet as I only have one LCD at the moment. Its all kind of crazy at the moment because my background in programming is non-existent. I can read code but don’t know if I’m writing it properly yet. Then again, thats what I like about microcontrollers. I can build circuits and code and actually see it happen. Its definitely got me interested again in becoming a better programmer and engineer.

So anyway, moving on…Here is the Arduino code I’m currently working with.

#include <LCD4Bit.h>

// Constants
#define DEBUG_LED = 13;

// Variables: Program definitions for user configurable settings.
int lcdRows = 4;
int charactersPerLine = 52;
int dotFormatPtn = 0×00;      //5×7 dots.  0×04 is 5×10
int usingRW = false;
int registerSelect = 6;
int readWrite = 7;
int enablePin1 = 0;
int enablePin2 = 1;
const int NUM_DB_PINS = 4;
int dataBits[NUM_DB_PINS] = {2, 3, 4, 5};

int test;

LCD4Bit lcd = LCD4Bit(lcdRows, charactersPerLine, dotFormatPtn, usingRW, registerSelect, readWrite, enablePin1, enablePin2, dataBits, NUM_DB_PINS);

void setup(){
  pinMode(13, OUTPUT); //we’ll use the debug LED to output heartbeat
  lcd.init();
  lcd.clear();
  lcd.cursorTo(3,0);  //select second displaycontroller, line 3, 4
  lcd.init();
  lcd.clear();
  }
 
void loop(){
  digitalWrite(13, HIGH); //light the debug LED
  lcd.cursorTo(1,0);
  lcd.printIn("WTF is up with this");

  lcd.cursorTo(2,10);
  lcd.printIn("Num of Lines: ");
  char buf[3];
  //lcd.printIn(itoa(charactersPerLine, buf, 16));
  lcd.numberWrite(charactersPerLine);
  lcd.cursorTo(3,0);
  lcd.printIn("To Visual C++ I go.");
  lcd.cursorTo(4,0);
 

    lcd.printIn(itoa(25, buf, 16));
 
  /* lcd.printIn("Debug: ");
  lcd.debugVariables(); */
  delay(1000);
  lcd.cursorTo(1,0); // select first two rows
  lcd.leftScroll(40, 80); //scroll first two rows
  //lcd.cursorTo(3,0); //select second displaycontroller, line 3, 4 
  //lcd.leftScroll(40, 80); //scroll third and fourth row
  delay(5000);
  digitalWrite(13, LOW);

  }

And I’ve zipped up and attached the current modification to the LCD4Bit library. Again, this is so not ready for anything serious. I need to add comments to the Wiring code and work a lot more on the library. I’ll work on all that.

My next major mod to the LCD4Bit code will be to get it working properly with a shift register. This is important as I need to keep Arduino pin usage to a bare minimum to ensure there is also room for Xbee, RFID, a keypad, and GPS.

Haha, this will definitely be interesting.

del.icio.us:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library digg:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library spurl:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library wists:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library simpy:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library newsvine:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library blinklist:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library furl:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library reddit:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library fark:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library blogmarks:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library Y!:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library smarking:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library magnolia:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library segnalo:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library

So I’ve been playing around with the Arduino now for a month or two and trying to interface it with a few of the Parallax accessories I have lying around. I’ve been meaning to post stuff here the whole time but was lazy. Anyway, here is some modified Wiring code for Arduino to use the Parallax RFID reader for those that might find it useful.

// RFID reader for Arduino
// Wiring version by BARRAGAN <http://people.interaction-ivrea.it/h.barragan>
// Modified for Arudino by djmatic
// And pieces from Arduino Playground <http://www.arduino.cc/playground/Learning/PRFID>
// And then modified again by thekidd

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3
#define ledPin 13

// set up a soft serial port
SoftwareSerial mySerial(rxPin, txPin);

int  val = 0;
char code[10];
int bytesread = 0;

void setup() {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);    // Set rxPin as INPUT to accept SOUT from RFID pin
  pinMode(txPin, OUTPUT);   // Set txPin as OUTPUT to connect it to the RFID /ENABLE pin
  pinMode(ledPin, OUTPUT);  // Let the user know whats up

  // set the data rate for the serial ports
  mySerial.begin(2400);    // RFID reader SOUT pin connected to Serial RX pin at 2400bps
  Serial.begin(9600);      // Serial feedback for debugging in Wiring

  // say something
  Serial.println("Hello World!");
}

 void loop() {
  digitalWrite(txPin, LOW);           // Activate the RFID reader
  digitalWrite(ledPin, LOW);          // Turn off debug LED
  
  if((val = mySerial.read()) == 10) { // check for header
    bytesread = 0;
   
    while(bytesread<10) {             // read 10 digit code
      val = mySerial.read();
     
      if((val == 10)||(val == 13)) {  // if header or stop bytes before the 10 digit reading
        break;                        // stop reading
      }
     
      code[bytesread] = val;          // add the digit          
      bytesread++;                    // ready to read next digit 
    }
   
    if(bytesread == 10) {             // If 10 digit read is complete
      digitalWrite(txPin, HIGH);      // deactivate RFID reader
      digitalWrite(ledPin, HIGH);     // activate LED to show an RFID card was read
      Serial.print("TAG code is: ");  // possibly a good TAG
      Serial.println(code);           // print the TAG code
    }
   
    bytesread = 0;
    delay(2000);                      // wait for a second to read next tag
  }
}


Some pics of it all in action:

Arduino + Parallax RFID Circuit

Parallax RFID reading tag

Tag Displayed in Wiring Serial Monitor

Next on the agenda is to use SoftwareSerial to communicate with the Parallax GPS unit via NEMA. Once that is done, I want to integrate the GPS with RFID reader and my Purdy LCD (4×40 - I know, its huge).

References:
Arduino Playground: Parallax RFID reader: http://www.arduino.cc/playground/Learning/PRFID
Arduino Forums: SoftwareSerial + RFID: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1176181152/30

del.icio.us:Interfacing Arduino with Parallax RFID reader using SoftwareSerial digg:Interfacing Arduino with Parallax RFID reader using SoftwareSerial spurl:Interfacing Arduino with Parallax RFID reader using SoftwareSerial wists:Interfacing Arduino with Parallax RFID reader using SoftwareSerial simpy:Interfacing Arduino with Parallax RFID reader using SoftwareSerial newsvine:Interfacing Arduino with Parallax RFID reader using SoftwareSerial blinklist:Interfacing Arduino with Parallax RFID reader using SoftwareSerial furl:Interfacing Arduino with Parallax RFID reader using SoftwareSerial reddit:Interfacing Arduino with Parallax RFID reader using SoftwareSerial fark:Interfacing Arduino with Parallax RFID reader using SoftwareSerial blogmarks:Interfacing Arduino with Parallax RFID reader using SoftwareSerial Y!:Interfacing Arduino with Parallax RFID reader using SoftwareSerial smarking:Interfacing Arduino with Parallax RFID reader using SoftwareSerial magnolia:Interfacing Arduino with Parallax RFID reader using SoftwareSerial segnalo:Interfacing Arduino with Parallax RFID reader using SoftwareSerial

Next »