const int photoResistorPin = A0; // Analog pin for the photoresistor
const int redPin = 9; // PWM pin for the red channel of the RGB LED
const int greenPin = 10; // PWM pin for the green channel of the RGB LED
const int bluePin = 11; // PWM pin for the blue channel of the RGB LED
void setup() {
Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
int photoValue = analogRead(photoResistorPin); // Read the analog value from the photoresistor
Serial.println(photoValue); // Print the photoresistor value for debugging
// Map the photoresistor value to an RGB color range
int redValue = map(photoValue, 0, 1023, 0, 255);
int greenValue = map(photoValue, 0, 1023, 0, 255);
int blueValue = map(photoValue, 0, 1023, 0, 255);
analogWrite(redPin, redValue); // Set the red channel of the RGB LED
analogWrite(greenPin, greenValue); // Set the green channel of the RGB LED
analogWrite(bluePin, blueValue); // Set the blue channel of the RGB LED
delay(100); // Delay for better readability (adjust as needed)
}