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!


Revision of Assignment 3 - Potentiometers from Wed, 09/26/2007 - 00:06

Project Members: 
Wesley Willett

 

Assignment 

Bland, boring, basic potentiometer setup. No time to turn it into anything cool. I set up two potentiometers and used one to control the brightness of the three LEDs and the other to control their on/off frequency.

Components Used

Arduino Board
Breadboard
Potentiometers (2)
LEDs (Green, Blue, Yellow)
Jumpers (3)
220 Ohm Resistors (3)
Lengths of wire (13)

Arduino Code

/*
* One potentiometer controls the brightness of the LEDs and one controls their frequency
 */
int potPin1 = 1;
int potPin2 = 2;
int pCellPin1 = 0;
int ledPin = 9;   // select the pin for the LED

int input0val = 0;
int input1val = 0;      // variable to store the value coming from pot 1
int input2val = 0;      //variable to store the value coming from pot 2

int brightval = 0;
int delayval = 0;

void setup() {
  Serial.begin(9600);
}
void loop() {
  input0val = analogRead(pCellPin1);
  input1val = analogRead(potPin1);    // read the value from the sensor, between 0 - 1024
  input2val = analogRead(potPin2);     // read the value from the sensor, between 0 - 1024
 
  brightval = input1val;
  delayval = input2val;
 
  Serial.print("photocell: ");
  Serial.print(input0val);
  Serial.print(" brightness: ");
  Serial.println(brightval);
  Serial.print(" delay: ");
  Serial.println(delayval);
  analogWrite(9, brightval/4); // analogWrite can be between 0-255
  analogWrite(10, brightval/4);
  analogWrite(11, brightval/4);
  delay(delayval);
  analogWrite(9, 0); // analogWrite can be between 0-255
  analogWrite(10, 0);
  analogWrite(11, 0);
  delay(delayval);
}

 Item

Potentiometers controlling LED Brightness & Blink

Potentiometers controlling LED Brightness & Blink

 


Powered by Drupal - Design by Artinet