Testrepo für alle Tests rund um Sensoren
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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. }