analog value works

This commit is contained in:
Milad Mohtashamirad 2025-08-17 14:46:56 +10:00
parent 529c78ce45
commit 75c0a2af6e
1 changed files with 7 additions and 2 deletions

View File

@ -1,3 +1,4 @@
// Blink LED on pin 13, read analog input from A0, and print to Serial
void setup() {
pinMode(13, OUTPUT); // Set pin 13 as output
@ -6,10 +7,14 @@ void setup() {
void loop() {
digitalWrite(13, HIGH); // Turn the LED on
Serial.println("LED ON"); // Print status
int analogValue = analogRead(A0); // Read analog value from A0
Serial.print("LED ON - Analog Value: ");
Serial.println(analogValue); // Print the analog value
delay(1000); // Wait 1 second
digitalWrite(13, LOW); // Turn the LED off
Serial.println("LED OFF"); // Print status
analogValue = analogRead(A0); // Read analog again
Serial.print("LED OFF - Analog Value: ");
Serial.println(analogValue); // Print the analog value
delay(1000); // Wait 1 second
}