/* Analog Input to LED Demonstrates analog input by reading an analog sensor (PHOTOTRANSISTOR) on analog pin 0 and turning on and off a light emitting diode(LED) connected to digital pin 7. The amount of time the LED will be on and off depends on the value obtained by analogRead(). This code is optimised for usage with the ATTiny44A created by David Cuartielles modified 30 Aug 2011 By Tom Igoe modified 12 Mar 2019 by Joey van der Bie This example code is in the public domain. http://www.arduino.cc/en/Tutorial/AnalogInput */ const int PHOTOTRANSISTOR_PIN = A2; // select the input pin for the PHOTOTRANSISTOR const int LED_PIN = 7; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor void setup() { // declare the LED pin as an OUTPUT: pinMode(LED_PIN, OUTPUT); } void loop() { // read the value from the sensor: sensorValue = analogRead(PHOTOTRANSISTOR_PIN); // turn the ledPin on digitalWrite(LED_PIN, HIGH); // stop the program for milliseconds: delay(sensorValue); // turn the ledPin off: digitalWrite(LED_PIN, LOW); // stop the program for for milliseconds: delay(sensorValue); }