//Automatic Car Lights- from ChatGPT //modified by Pat McMahon- 26/4/2026 //I asked ChatGPT-"Using the Arduino IDE and a Uno, code a sketch to turn on an led when an attached LDR is covered up, off when open to light". // I then modified the code for 3 LEDS, Blue,Orange and Red. const int ldrPin = A0; // LDR connected to analog pin A0 const int BlueledPin = 9; // LED connected to digital pin 9 const int OrangeledPin = 10; // LED connected to digital pin 10 const int RedledPin = 11; // LED connected to digital pin 11 int lightValue = 0; int threshold = 400; // Adjust this after testing void setup() { pinMode(BlueledPin, OUTPUT); pinMode(OrangeledPin, OUTPUT); pinMode(RedledPin, OUTPUT); Serial.begin(9600); // For debugging } void loop() { lightValue = analogRead(ldrPin); Serial.println(lightValue); // See values in Serial Monitor if (lightValue < threshold) { // DARK → LED ON digitalWrite(BlueledPin, HIGH); digitalWrite(OrangeledPin, HIGH); digitalWrite(RedledPin, HIGH); } else { // LIGHT → LED OFF digitalWrite(BlueledPin, LOW); digitalWrite(OrangeledPin, LOW); digitalWrite(RedledPin, LOW); } delay(200); }