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:
|