The SM-1 Project Part 2: Installing the servo on the lamp @seeedstudio #arduino

The SM-1 Project Part 2: Installing the servo on the lamp:

I have to be honest: this is my first time working with servos, but not the first time i modify this IKEA Lamp (check this mod for Iphone i made and which i use to record this video).

Watch the servo working on the lamp:

We continue the developing of our SM-1 Lamp Robot, this time we are doing hacks on the lamp to install one servo, the one that will move the lamp head to the sides (as if the lamp looks to each side).

Here is the detail of the lamp head:

Let´s dissarm all of it. Also we should remove all the electrical parts of the original lamp. We are not going to use a 220v lamp, but instead we are going to need all this space to install some sensors.

This is how it shoul look without the lamp head. See in the background the lamp head allready without the electrical parts:

Now, we are using some spare parts (also from IKEA), from the EXPEDIT furniture. They come with some metal supports in case you are attaching the furniture to the wall (which i never do), and these parts fit perfectly in the lamp and hold perfectly also the servo.

Now, lets drill the lamp head to attach it to the servo arm.

And this is how it looks!!! Looks almost as terminator isn´t it? 😉

For the video demostration, we used the Knob Servo Example from Arduino IDE.

The Code for Knob Example:

// Controlling a servo position using a potentiometer (variable resistor) 
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott> 

#include <Servo.h> 

Servo myservo;  // create servo object to control a servo 

int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin 

void setup() 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object void loop() 
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180) 
  myservo.write(val);                  // sets the servo position according to the scaled value 
  delay(15);                           // waits for the servo to get there 


Related Posts