Arduino lamp

I’ve always had this childish dream of having all my electronics coupled together, operating in unison and communicating with a central system that can coordinate and control everything.

Today I’m finally one step closer, since I can now operate my desk lamp through email.

I first made this lamp for the Idéfestival at the University in Oslo. The kids thought it was a lot of fun playing with it, sending email from a big iMac and having the light switch on and off.

Yesterday I decided to do the same to my own desk lamp. I built a simple contraption to hold the servo over the switch and hooked it up to my arduino. I used the software from the lamp I made for the university and everything was up and running in half an hour.

In essence it’s a small sketch for the arduino that checks the serial bus for a signal and if it receives a “0” is turns the servo to 120° and if it receives a “1” is turns to 90°.

#include  

Servo myservo;

void setup(){
  Serial.begin(9600);
}

void loop(){
  if (Serial.available() > 0) {
    char input = Serial.read();

    if(input == 1){
      skruPaa();
    }if(input == 0){
      skruAv();
    }
  }
}

void skruPaa(){        // Turn on the light
  myservo.attach(9);   // Connect to the servo on pin 9
  myservo.write(90);   // Turn the servo to 90°
  delay(200);          // Give the servo some time to finish
  myservo.detach();    // Detach the servo, so it will turn 
                       // off and not keep pressure on the switch
}

void skruAv(){
  myservo.attach(9);
  myservo.write(120);
  delay(200);
  myservo.detach();
}

The Java code can be found here: Email light switch java source code. It is based off of this example http://arduino.cc/playground/Interfacing/Java and should be mostly platform independent. You will need to modify settings.xml with you email and password and possibly also the port for the arduino. If you don’t know this, it’s the same as you can see in the arduino software under “Tools”->”Serial port”. A precompiled jar file can be found in ./out/artifacts/Email_light_switch_jar/Email_light_switch.jar (remember to edit the settings.xml file in that directory as well).

Below you can see a video of the lamp and closeups of the different parts.

  • lamp with light
  • lamp front
  • lamp right
  • lamp left
  • lamp top
  • lamp front without light
[youtube]_zuYrajP0Cg[/youtube]

Comments are Disabled