Source

articles_code / arduino_article / listing3.pde

Full commit
amitksaha 6bed469 

































/* Using potentiometer to fade on/off a LED
*  Original code notice below:
* ------------------------------
* Demonstrates analog input by reading an analog sensor on analog
* pin 0 and turning on and off a light emitting diode(LED) connected to
*  digital pin 13.
* The amount of time the LED will be on and off depends on the value obtained by
* analogRead().
* Created by David Cuartielles
* Modified 16 Jun 2009
* By Tom Igoe
* http://arduino.cc/en/Tutorial/AnalogInput
*/

int sensorPin = 0;
int ledPin = 13;
int sensorValue = 0;

void setup() {
     //declare the ledPin as an OUTPUT:
     pinMode(ledPin, OUTPUT);
     Serial.begin(9600);
}

void loop() {
	sensorValue = analogRead(sensorPin);//

	digitalWrite(ledPin, HIGH);

	delay(sensorValue);

	digitalWrite(ledPin, LOW);

	delay(sensorValue);
}