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!


POT LED dimming

Project Members: 
cjgoetz

Description:  Here two soldered POT(entiometers) are wired to a breadboard and are controlling the dimming of three LED lights under a homemade diffuser.  I changed a given code around so that I could fade two LED's (blue/green) independently from the red LED with my two POT's.

Components:
(1) Breadboard; Arduino Board; bottle cap; usb wire; black ground wire; tissue cup
(2) Rubber Bands; bathroom tissues; potentiometers; yellow wires redirecting power from the POT's; Red Wires feeding current into the POT's; Brown wires grounding the POT's
(3) 220-ohm resistors; yellow wires feeding the resistors; blue wires grounding the LEDs; Differently-colored LEDs

Code:
/*
 * one pot dims, the other pot changes the blinking rate
 * modification of the following
 * http://www.arduino.cc/en/Tutorial/AnalogInput
 */
int pot1Pin = 2;   // select the input pin for the potentiometer 1
int pot2Pin = 4;   // select the input pin for the potentiometer 2
int pot1Val = 0;   // variable to store the value coming from pot 1
int pot2Val = 0;   // variable to store the value coming from pot 2
int led1Pin = 9;   // select the pin for the LED 1
int led2Pin = 10;  // select the pin for the LED 2
int led3Pin = 11;
void setup() {
   pinMode(led1Pin, OUTPUT);  // declare the led1Pin as an OUTPUT
   pinMode(led2Pin, OUTPUT);  // declare the led2Pin as an OUTPUT
   pinMode(led3Pin, OUTPUT);
}
void loop() {
   pot1Val = analogRead(pot1Pin);   // read the value from pot 1, between 0 - 1024, for dimming
   pot2Val = analogRead(pot2Pin);   // read the value from pot 2, between 0 - 1024, for blinking
   analogWrite(led2Pin, pot1Val/4); // dim LED to value from pot1
   analogWrite(led3Pin, pot1Val/4);
   analogWrite(led1Pin, pot2Val/4);
// delay(pot2Val);                  // stop the program for some time, meaning, LED is on for this time
// analogWrite(led2Pin, 0);         // dim LED to completely dark (zero)
// delay(pot2Val);                  // stop the program for some time, meaning, LED is OFF for this time
}

Images:

RedRed


Comments

at first, i had no idea what

at first, i had no idea what you meant my entiometers. Then I realized what you were doing :) nice job!


Powered by Drupal - Design by Artinet