O Level Exam : Practical Question
📝 HTML
🎨 CSS
⚡ Java Script
#define POT_PIN A0 #define BUTTON_PIN 2 void setup() { Serial.begin(9600); pinMode(BUTTON_PIN, INPUT_PULLUP); } void loop() { int potValue = analogRead(POT_PIN); // Read analog sensor int buttonState = digitalRead(BUTTON_PIN); // Read digital sensor Serial.print("Potentiometer Value: "); Serial.print(potValue); Serial.print(" | Button State: "); if (buttonState == HIGH) Serial.println("Pressed"); else Serial.println("Not Pressed"); delay(1000); }
▶ Run Code
🖥 Output: