/* * one pot fades one led * modified version of AnalogInput * by DojoDave * http://www.arduino.cc/en/Tutorial/AnalogInput */ int potPin = 2; // select the input pin for the potentiometer int ledPin = 9; // select the pin for the LED int val = 0; // variable to store the value coming from the sensor void setup() { Serial.begin(9600); } void loop() { val = analogRead(potPin); // read the value from the sensor, between 0 - 1024 Serial.println(val); analogWrite(ledPin, val/4); // analogWrite can be between 0-255 }