Friday, August 29, 2008

Bluetooth Controlled Lights

Today I finally finished my wireless colored lights that are controlled with bluetooth. I used the BlueSMIRF Gold on one of the Axon's UART lines and wrote up a program that "listens" on the BlueSMIRFs Rx line ( the line where the incoming serial data is) for the key presses. There are four colors of LEDs and each is controlled by the first letter of the color ( the code for white is "w" ). I used ZTerm on MacOSX as the terminal emulator . It has extremely long range as well - I can control the lights from the second floor when the lights are in the basement.




Here is the code used:

Defines:
// *************** Bluetooth Lights ****************
#define blue_on PORT_ON(PORTC,0)
#define yellow_on PORT_ON(PORTC,1)
#define red_on PORT_ON(PORTC,2)
#define white_on PORT_ON(PORTC,3)
void all_off(void)
{
PORT_OFF(PORTC,0);
PORT_OFF(PORTC,1);
PORT_OFF(PORTC,2);
PORT_OFF(PORTC,3);
} // end routine
// *************END BLUETOOTH Setup******************


Code (example show is for blue only , just change the letter and color for the others):

char cByte = uart0GetByte(); // get byte from UART0 on the axon
if (cByte == 'b') // if character received is b then
{
all_off(); // turn all LEDs off
blue_on; // turn only blue LED on
}


3 comments:

JeFX said...

This is fantastic! I want to be able to do something like this for a home lighting setup. Do you have some documentation for those who may not be so mechanically inclined such as yourself?

Eric said...

pop me an email and I'd be happy to help

Susanna said...

This is a fantastic idea for my senior project but i wanna use it in household lighting control. Where if i am in bed and the closest thing to me is my cell phone, i can jus turn off the lights in different areas of the house using this. Can i get some documentation on this so i can try settting it up please?