Potentiometer Love

Posted by Jake Good
on May 23, 08
drop.io: simple private sharing


Here's a simple demonstration of controlling the speed of a blinking LED with a potentiometer...

And the code:

/* Setup pins */
int potPin = 2;
int ledPin = 13;
int v = 0;

/* Set LED to Output */
void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  /* Read from potentiometer */
  v = analogRead(potPin);
  /* Turn LED on */
  digitalWrite(ledPin, HIGH);
  /* Wait relative to where potentiometer value is */
  delay(v);
  /* Turn LED off */
  digitalWrite(ledPin, LOW);
  /* Wait again */
  delay(v);
}
Comments

Leave a response

Comment