Physical Computing Homework Assignment: Love-o-Meter
September 18th, 2008The title of my submission for this assignment is “The Obameter,” which is a play on the last name of Democratic Presidential Candidate Barack Obama. It is a picture frame with a potentiometer and 5 LEDs built in.
The frame was “re-purposed” from the PCOMP Woodshop bins. I used the circular saw and the drill press to make the hole. I also used a chisel to ensure the proper fit of the potentiometer. I used another piece of scrap wood to create the base. When the physical aspect of the Obameter was complete, I took it home and applied Stain and Polyurethane to give it a nicer finish.
The Obameter works in the following fashion. There are 5 lights at the top. The user is requested to react to the picture within the frame, by turning the knob based on the level of his/her favor. In this case, if the knob is turned only a little bit, the lights are lit from the left hand side of the frame in the color red. As the user turns the knob more clockwise, the remaining lights will shine.
There are icons placed around the potentiometer knob to guide the user as to the intensity of their appreciation for the person in the picture. In this case, the icons are for the Republican Party, The Democratic Party. If the user turns the know too far past the Democratic Party icon, the Yellow light will turn on indicating either its someone who likes the person in the picture too much (Stalker) or is perhaps a member of the sycophant Left Wing Liberal Media (joke).













The code for this project is fairly simple. It is as follows:
int potPin = 0; // Analog input pin that the potentiometer is attached to
int potValue = 0; // value read from the pot
int led1 = 3; // PWM pin that the LED is on. n.b. PWM 0 is on digital pin 3
int led2 = 5; // PWM pin that the LED is on. n.b. PWM 0 is on digital pin 5
int led3 = 6; // PWM pin that the LED is on. n.b. PWM 0 is on digital pin 6
int led4 = 9; // PWM pin that the LED is on. n.b. PWM 0 is on digital pin 9
int led5 = 4; // PWM pin that the LED is on. n.b. PWM 0 is on digital pin 4
int buzzer = 2;
int chime = 6;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
potValue = analogRead(potPin); // read the pot value
Serial.println(potValue); // print the pot value back to the debugger pane
if(potValue > 0)
{
analogWrite(led1, potValue/6); // PWM the Red LED with the pot value (divided by 4 to fit in a byte)
delay(100);
analogWrite(led1, 0);
}
if(potValue > 200)
{
analogWrite(led2, potValue/6); // PWM the 2nd Red LED with the pot value (divided by 4 to fit in a byte)
delay(100);
analogWrite(led2, 0);
}
if(potValue > 400 )
{
analogWrite(led3, potValue/6); // PWM the Green LED with the pot value (divided by 4 to fit in a byte)
delay(100);
analogWrite(led3, 0);
analogWrite (chime,0);
}
if(potValue > 600 )
{
analogWrite(led4, potValue/6); // PWM the Blue LED with the pot value (divided by 4 to fit in a byte)
delay(100);
analogWrite(led4, 0);
}
if(potValue > 800 )
{
analogWrite(led5, potValue/6); // PWM the Yellow LED with the pot value (divided by 4 to fit in a byte)
delay(100);
analogWrite(led5, 0);
}
delay(10); // wait 10 milliseconds before the next loop
}