Testrepo für alle Tests rund um Sensoren
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
502B

  1. #include "Arduino.h"
  2. #include <hcsr04.h>
  3. #define TRIG_PIN 12
  4. #define ECHO_PIN 11
  5. HCSR04 sr04(TRIG_PIN,ECHO_PIN);
  6. long a;
  7. //The setup function is called once at startup of the sketch
  8. void setup()
  9. {
  10. // Add your initialization code here
  11. Serial.begin(9600);
  12. Serial.println(__FILE__);
  13. delay(1000);
  14. }
  15. // The loop function is called in an endless loop
  16. void loop()
  17. {
  18. //Add your repeated code here
  19. a=sr04.distanceInMillimeters();
  20. Serial.print(a);
  21. Serial.println("mm");
  22. delay(1000);
  23. }