Skip to content

Instantly share code, notes, and snippets.

@upsilun
Created January 13, 2025 21:36
Show Gist options
  • Save upsilun/75a7ae6f822a245e6583cc683a5d4b20 to your computer and use it in GitHub Desktop.
Save upsilun/75a7ae6f822a245e6583cc683a5d4b20 to your computer and use it in GitHub Desktop.
const int pwmInputPin = 3;
void setup() {
Serial.begin(9600);
pinMode(pwmInputPin, INPUT);
Serial.println("Reading PWM signal...");
}
void loop() {
unsigned long pulseWidth = pulseIn(pwmInputPin, HIGH);
if (pulseWidth > 0) {
Serial.println(pulseWidth);
} else {
Serial.println("No signal detected.");
}
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment