20 lines
765 B
C++
20 lines
765 B
C++
// Blink LED on pin 13, read analog input from A0, and print to Serial
|
|
|
|
void setup() {
|
|
pinMode(13, OUTPUT); // Set pin 13 as output
|
|
Serial.begin(115200); // Start serial communication at 9600 baud
|
|
}
|
|
|
|
void loop() {
|
|
digitalWrite(13, HIGH); // Turn the LED on
|
|
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
|
|
analogValue = analogRead(A0); // Read analog again
|
|
Serial.print("LED OFF - Analog Value: ");
|
|
Serial.println(analogValue); // Print the analog value
|
|
delay(1000); // Wait 1 second
|
|
} |