This is my code for the Nano.
//Constants
const int pResistor = A0; // Photoresistor at Arduino analog pin A0
const int soundEffect=9; // Led pin at Arduino pin 9
//Variables
int value; // Store value from photoresistor (0-1023)
void setup(){
pinMode(soundEffect, OUTPUT); // Set lepPin - 9 pin as an output
pinMode(pResistor, INPUT);// Set pResistor - A0 pin as an input (optional)
}
void loop(){
value = analogRead(pResistor);
//You can change value "25"
if (value > 750){
digitalWrite(soundEffect, HIGH); //Turn led off
}
else{
digitalWrite(soundEffect, LOW); //Turn led on
}
}