Announcements

November 24, 2007
Reading for November 27th, are now posted. Enjoy!

October 2, 2007
To upload your thoughtless acts, create a new assignment page like any other lab. You'll see "Thoughtless Acts" listed as one of the assignment options.

May 24, 2008
This site has been archived and is no longer editable. Stay tuned for the next version, coming in the fall!


Soldering/Connecting Pot/Pot controlling LED

Project Members: 
Katherine Ahern

Description:

I didn't get to hooking up 2 potentiometers, and the one I did hook up didn't behave exactly as expected, but I got the LED to take readings from the pots and then blink in a kind of unusual cool way. The values I got from the potentiometer were 38, 39, and 40, so what I did was take the difference of the value from 40 (0, 1, or 2), and mutliply it by so the LED got values of 0, 127, or 254 - it would go off, blink mid-bright, then all the way up, but not completely in a set pattern.

Components:

1 potentiometer, with 3 wires soldered on
2 additional wires
1 resistor
1 LED

Picture:

Arduino Code:
// This program wires a potentiometer to a LED
// The pot lets you control the brightness of the corresponding LED
// The pot values seem to go 38, 39, 40 - sometimes out of order or repeating
// So the light flashes bright, mid-level, or off, but not in a totally regular pattern
// adapted from http://www.andrew.cmu.edu/user/atriulzi/lamp/lamp.txt
// by Katherine Ahern

int value1 = 0; //Pot value of Blue LED
int value2 = 127; //doin' some funky stuff to get more variance in the LED
int value3 = 0;
int oneTwoThree = 0;
int ledpin1 = 9; //Blue LED
int pot1 = 1; //Designates Potentiometer for this LED

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

void loop()
{

Serial.print("pot: "); //used to test
Serial.println(value1); //the value of the
delay(500); //potentiometer
Serial.println(oneTwoThree); //the value of the difference between 40 and the output of the pot

value1 = analogRead(pot1);
oneTwoThree = 40 - value1;
analogWrite(ledpin1, oneTwoThree * value2 ); //this sends brightness between 0 and 254
delay(30); //potentiometer put out values from
//0 to 1000, but the Arduino determines
//how much power to send to the LED on a
//scale from 0 to 255. (1000/255 = ~4)

}


Comments

I wonder if it's obvious...

That I am SO NEW to physical computing that I didn't realize you twist the stem of the potentiometer to get the full range of values. 


I'm making a lot more progress now that I've figured that out...

o.m.g. hahaha :)

o.m.g. hahaha :)


Powered by Drupal - Design by Artinet