summaryrefslogtreecommitdiff
path: root/esp/src/lm393.cpp
diff options
context:
space:
mode:
authorGustavoeklund01 <eklundgu@gmail.com>2025-10-27 20:28:29 -0300
committerGustavoeklund01 <eklundgu@gmail.com>2025-10-27 20:28:29 -0300
commit7ccab61c22fafb3bb9fa5470ff8cb46217111fe4 (patch)
tree65a629f9f99277358e3aefc19fc43a057e079dc2 /esp/src/lm393.cpp
parentbe7952f3585fe895a3309a19e14cd93f89c3ce1b (diff)
outros códigos
Diffstat (limited to 'esp/src/lm393.cpp')
-rw-r--r--esp/src/lm393.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/esp/src/lm393.cpp b/esp/src/lm393.cpp
index e69de29..5eb4bdf 100644
--- a/esp/src/lm393.cpp
+++ b/esp/src/lm393.cpp
@@ -0,0 +1,26 @@
+#include <Arduino.h>
+#include "lm393.h"
+
+#define SENSOR_PIN 32 // ou 35 se preferir
+
+void setupLM393() {
+ pinMode(SENSOR_PIN, INPUT);
+}
+
+int lerLM393() {
+ static int contagem = 0;
+ static unsigned long lastTime = 0;
+
+ if (digitalRead(SENSOR_PIN) == LOW) {
+ contagem++;
+ delay(10);
+ }
+
+ if (millis() - lastTime >= 1000) {
+ int pulsos = contagem;
+ contagem = 0;
+ lastTime = millis();
+ return pulsos;
+ }
+ return 0;
+}