Desk lamp controlled by servo motor

The idea for this project was to make a small desk lamp where the amount of light was controlled by opening the top of the light using a potentiometer. The LEDs come on when the angle of the servo motor goes past 1 degree and the top opens up to the limit of the servo motor (180 degrees). At this point the light is fully exposed and shining up:

The major challenge with the enclosure was to anchor the motor sufficiently so that it would rotate the top rather than rotating itself.

Code:

// Controlling a servo position using a potentiometer (variable resistor)
// and using the same input to turn on an LED once the angle of the servo goes past 1 degree
// Credit to Michal Rinott <http://people.interaction-ivrea.it/m.rinott> for servo position code

#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
int ledPin = 13; // variable to write to the LED

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
pinMode(ledPin, OUTPUT); //
}

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
if (val>6) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}

// Controlling a servo position using a potentiometer (variable resistor)
// and using the same input to turn on an LED once the angle of the servo goes past 1 degree
// Credit to Michal Rinott <http://people.interaction-ivrea.it/m.rinott> for servo position code

#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
int ledPin = 13; // variable to write to the LED

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
pinMode(ledPin, OUTPUT); //
}

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
if (val>6) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}