/* ----------------------     analog_Light_Sensor    -----------------------
 *
 *   Hardware Setup- a voltage divider connected to analog pin A5:
 *   1) -Wire a photoresister between +5vdc and an empty row on the breadboard
 *   2) -Wire a 10k resistor between that same row on the breadboard to ground.
 *   3) -Jumper wire from that same row to the last pin on the chip (analog 0)
 *   4) -Wire an LED thru a 330 ohm resistor from digital pin 7 to gnd
 *
 *   -Note: This sketch introduces the map() function for scaling values
 *-------------------------------------------------------------------------*/
int a_in;               // create variable for storing analog readings
int sensorPin = A5;      // variable for analog pin as A5
int LEDpin = 7;         // variable for LED pin

void setup() {
  pinMode(LEDpin, OUTPUT);       // Set the digital LED pin as an output
}

void loop() {
  // read sensor, store in variable, print
  a_in = analogRead(sensorPin);       // get 10 bit analog value
  a_in = map(a_in, 0, 1023, 0, 255);  // scale it to 8 bits
  digitalWrite(LEDpin, HIGH);         // turn LED on
  delay(a_in);                        // analog reading is delay time 
  digitalWrite(LEDpin, LOW);          // turn LED off 
  delay(a_in); 
}