const int ledPin = D2; const int buttonPin = D10; const int photoPin = D0; int buttonState = 0; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT); pinMode(photoPin, INPUT); } void loop() { int lightLevel = analogRead(photoPin); Serial.println(lightLevel); delay(100); buttonState = digitalRead(buttonPin); // Read button state if (buttonState == HIGH) { // If button is pressed digitalWrite(ledPin, HIGH); // Turn LED on } else { digitalWrite(ledPin, LOW); // Turn LED off } } // void loop() { // // put your main code here, to run repeatedly: // digitalWrite(ledPin, HIGH); // delay(500); // digitalWrite(ledPin, LOW); // delay(500); // }