From 6fed254c8033bf4c67b65328474df6807c3b7eb8 Mon Sep 17 00:00:00 2001 From: Luiz Gustavo Monteiro Date: Tue, 28 Oct 2025 20:25:17 -0300 Subject: refactor folders schema --- esp/LM393.ino | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 esp/LM393.ino (limited to 'esp/LM393.ino') diff --git a/esp/LM393.ino b/esp/LM393.ino deleted file mode 100644 index 6e6a5d5..0000000 --- a/esp/LM393.ino +++ /dev/null @@ -1,42 +0,0 @@ -#define SENSOR_PIN 35 // pino de sinal (DO) - -unsigned long lastTime = 0; -unsigned int pulsos = 0; -int estadoAnterior = HIGH; // começa em HIGH (sem interrupção) - -// Configurações do sensor -const int PULSOS_POR_VOLTA = 10; // 10 furos = 10 pulsos por volta -const float FATOR_KMH = 2.4; // km/h por rotação por segundo (ajuste conforme calibração) - -void setup() { - Serial.begin(115200); - pinMode(SENSOR_PIN, INPUT); - Serial.println("Anemômetro LM393 - Velocidade do vento"); -} - -void loop() { - int estadoAtual = digitalRead(SENSOR_PIN); - - // Detecta borda de descida: HIGH → LOW - if (estadoAnterior == HIGH && estadoAtual == LOW) { - pulsos++; - } - - estadoAnterior = estadoAtual; // atualiza para próxima leitura - - // A cada 1 segundo calcula RPM e velocidade - if (millis() - lastTime >= 1000) { - float rps = (float)pulsos / PULSOS_POR_VOLTA; - float rpm = rps * 60.0; - float velocidade = rps * FATOR_KMH; - - Serial.print("RPM: "); - Serial.print(rpm); - Serial.print(" | Velocidade: "); - Serial.print(velocidade); - Serial.println(" km/h"); - - pulsos = 0; - lastTime = millis(); - } -} \ No newline at end of file -- cgit v1.2.3