Introduction:- Using an oscilloscope and an XIAO ESP32-C3 microcontroller, digital and analog signals are investigated and analyzed. An LED is used to monitor digital signals in the experiment, and an LDR (light-dependent resistor) sensor is used to produce analog signals. These signals are shown by the oscilloscope to aid with comprehension.
LED Daigram
We connected the LDR to pin 2 and an LED to pin 8. When the light level drops (i.e., it's dark), the LED turns on. When it's bright, the LED stays off.
#define LDR_PIN 0
void setup() {
Serial.begin(115200);
}
void loop() {
int ldrValue = analogRead(LDR_PIN);
Serial.println(ldrValue);
delay(500);
}
In this version, we used analog pin A1 to read LDR values. When the sensor detects darkness (value below 500), the LED on pin 8 turns on.
#define LDR_PIN 0
#define LED_PIN 8
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(115200);
}
void loop() {
int ldrValue = analogRead(LDR_PIN);
Serial.println(ldrValue);
if (ldrValue < 500) {
digitalWrite(LED_PIN, HIGH);
} else {
digitalWrite(LED_PIN, LOW);
}
delay(500);
}
Digital Signal With oscilloscope | Analog signal With oscilloscope |
The oscilloscope's CH1 successfully displayed the LDR's analog signal, which fluctuated continuously based on light intensity. The LED's digital signal appeared as a square wave, alternating between HIGH (3.3V) and LOW (0V).
By evaluating the circuit and software implementation, the oscilloscope helped confirm the behavior of the real-time signals.