// Activity 5 - Read a LightDependent Resistor int led1 = 11;// LED on pin 11 for feedback from LDR value int ldr = A0; // LDR connected to port A0 (analog port 0) int outVal = 0; // will be used for scaling the photocallInputValue to give more variation // in LED brightness int ldrVal; // the value of light hitting the LDR void setup() { pinMode(led1, OUTPUT); Serial.begin(9600); // open channel to the Serial Monitor } void loop() { ldrVal = analogRead(ldr);// read the level of light hitting the LDR outVal = map(ldrVal, 0, 1023, 0 , 255); // scales the input 0-1023 to 0-255 analogWrite(led1, outVal); // set the LED pin brightness Serial.println(outVal); // The delay can be changes to get the desired dimming effect delay(20); }