Bluetooth controlled lamp
While I’m testing the new Arduino bluetooth board I’m also building some examples to explore the different possibilities that it offers. I’ve started by reading a sensor and sending it to a mobile phone and now i’ve tried something less abstract. I’ve got a cheap (14.95 EUR) Ikea Fado lamp and hooked it up to an Arduino BT board then I wrote a simple piece of code that would change the brightness of an LED depending on a message coming from the bluetooth interface. Then i started reading Jurgen Scheible’s tutorial on how to write python programs for the Nokia Series 60. After a couple of days of hacking I have the app up and running.
Basically you can browse for all the bluetooth devices in the area and select the lamp you want to control then you can turn it on and off from a menu. Once it has been mapped you don’t need to browse it again. next step the colour….
Action shots coming soon. In the rest of the post you can read some more about how i built it.
The code is ridiculously simple…
/* Bluatooth controlled Lamp
* ——————
* Massimo Banzi m.banzi (at) tinker.it
*
*/
int LED = 13; // select the pin for the LED
int RESET = 7;
int val = 0; // variable to store the data from the serial port
void setup() {
pinMode(LED,OUTPUT); // declare the LED’s pin as output
pinMode(RESET,OUTPUT); // declare the RESET pin as output
Serial.begin(115200); // connect to the serial port
// Reset the bluetooth interface
digitalWrite(RESET, HIGH);
delay(10);
digitalWrite(RESET, LOW);
delay(2000);
//configure the bluetooth module
Serial.println(”SET BT PAGEMODE 3 2000 1″);
Serial.println(”SET BT NAME BTLAMP”);
Serial.println(”SET BT ROLE 0 f 7d00″);
Serial.println(”SET CONTROL ECHO 0″);
Serial.println(”SET BT AUTH * 12345″);
Serial.println(”SET CONTROL ESCAPE - 00 1″);
}
void loop () {
val = Serial.read();
// if the input is ‘-1′ then there is no data
// otherwise read a digit between 0 and 9
// where 0 is off and 9 is full brightness
if (val != -1) {
val = (val - 48) * 28; // transform the ASCII code into the numeric value
analogWrite(9, val);
}
}
The Arduino board is hooked up to a voltage controlled dimmer that can drive the small incandescent bulb inside the lamp. the circuit is small enough to fit inside the base of the lamp. At the moment the arduino is still powered by batteries.. I have to include a small switching power supply for project to be finished.
The next installment will use LED bars replacing the incandescent bulb and will use a small power supply to provide the 24V needed by the LEDs.
4 Comments »
RSS feed for comments on this post. TrackBack URL
Congrats on all your hard work!!! Many of us understand how limitless the fruits of your labor will be! I for one dream about a bluetooth toe-switch inside my shoe so that I can tempo-sync a sample played off a keyboard as I dj vinyl. I feel you and a handful of special others are propelling us into an age of “electronic magic” as proposed by Mike Kuniavsky’s ( http://www.orangecone.com/archives/2006/10/the_coming_age.html ) Thanks and keep it up!
come on!
come on!
come on!
BT Arduino for the whole world!!!
[...] With the Arduino Bluetooth boards not that far away, it’s getting seriously cheap and easy for the artist (rather than the engineer) to build wireless gadgets, too. [...]
Hi,
Im an industrial design student doing almost exactly the same project. Do you think you could email me the python code you used. It would save me sooo much work on starting from scratch.
im having currently a love/hate relationsip with my arduino.
angelo.