O Level Exam : Practical Question
📝 HTML
🎨 CSS
⚡ Java Script
void setup() { Serial.begin(9600); pinMode(A0, INPUT); pinMode(2, INPUT); } void loop() { // Read analog data from the LDR int lightValue = analogRead(A0); // Read digital data from the IR sensor int obstacleStatus = digitalRead(2); Serial.print("LDR Analog Value: "); Serial.print(lightValue); Serial.print(" PIR Sensor: "); if (obstacleStatus == LOW) { Serial.println("Obstacle Detected"); } else { Serial.println("No Obstacle"); } delay(1000); }
▶ Run Code
🖥 Output: