Assignment 10.1

posted Jul 16, 2010, 8:48 PM by Unknown user   [ updated Jul 30, 2010, 9:41 AM ]
For this one I used a potentiometer connected to analog pin 1 to control the brightness of an LED connected to digital pin 9.
Here's my code:
 
int val = 0;
int ledPin = 9;
int potPin = 1;
void setup() {
  //twiddle your thumbs
}
void loop() {
  val = analogRead(potPin);
  val = map(val, 0, 1023, 0, 225);
  analogWrite(ledPin, val);
  delay(30);
}
 
Here's a Fritzing pic of my circuit:
 
 
 
Comments