Smart-Home am Beispiel der Präsenzerkennung im Raum Projektarbeit Lennart Heimbs, Johannes Krug, Sebastian Dohle und Kevin Holzschuh bei Prof. Oliver Hofmann SS2019
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HC_SR04.ino 413B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <NewPing.h>
  2. #define TRIGGER_PIN 4
  3. #define ECHO_PIN 3
  4. #define MAX_DISTANCE 200
  5. NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
  6. void setup() {
  7. Serial.begin(9600);
  8. }
  9. void loop() {
  10. delay(50);
  11. unsigned int uS = sonar.ping();
  12. pinMode(ECHO_PIN,OUTPUT);
  13. digitalWrite(ECHO_PIN,LOW);
  14. pinMode(ECHO_PIN,INPUT);
  15. Serial.print("Ping: ");
  16. Serial.print(uS / US_ROUNDTRIP_CM);
  17. Serial.println("cm");
  18. }