Based on Pflichtenheft v2.2, documents the full system design including daemon, API, frontend, and infrastructure with agreed deviations (Axum 0.8, SQLx 0.8, Vite 6, Tailwind 4). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
// HC-SR04 Test Programm
|
|
// Dieses Programm testet nur den HC-SR04 Sensor ohne LoRaWAN
|
|
|
|
#include <Arduino.h>
|
|
#include <HCSR04.h>
|
|
|
|
// HC-SR04 Pins
|
|
#define TRIG_PIN 12
|
|
#define ECHO_PIN 13
|
|
|
|
HCSR04 distanceSensor(TRIG_PIN, ECHO_PIN);
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
delay(2000);
|
|
Serial.println("HC-SR04 Sensor Test");
|
|
Serial.println("==================");
|
|
Serial.print("TRIG Pin: GPIO ");
|
|
Serial.println(TRIG_PIN);
|
|
Serial.print("ECHO Pin: GPIO ");
|
|
Serial.println(ECHO_PIN);
|
|
Serial.println();
|
|
}
|
|
|
|
void loop() {
|
|
// Distanz messen
|
|
float distance = distanceSensor.dist();
|
|
|
|
Serial.print("Roher Wert: ");
|
|
Serial.print(distance);
|
|
Serial.print(" cm");
|
|
|
|
if (distance < 0) {
|
|
Serial.println(" -> FEHLER (Sensor antwortet nicht)");
|
|
} else if (distance == 0) {
|
|
Serial.println(" -> 0 cm (zu nah oder kein Echo)");
|
|
} else if (distance > 400) {
|
|
Serial.println(" -> Zu weit (außerhalb Messbereich)");
|
|
} else {
|
|
Serial.print(" -> OK (");
|
|
Serial.print(distance * 10);
|
|
Serial.println(" mm)");
|
|
}
|
|
|
|
delay(1000); // 1 Sekunde warten
|
|
}
|