Advertisement
tomateblue

DistanciUltraSom

Sep 24th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <Ultrasonic.h>
  2.  
  3. #define pino_trigger 4
  4. #define pino_echo 5
  5. int distancia;
  6.  
  7. //Inicializa o sensor nos pinos definidos acima
  8. Ultrasonic ultrasonic(pino_trigger, pino_echo); // (Trig PIN,Echo PIN)
  9.  
  10. void setup() {
  11. Serial.begin(9600);
  12. }
  13.  
  14. void loop()
  15. {
  16.  
  17.  distancia = ultrasonic.Ranging(CM);
  18.  Serial.print(distancia); // CM or INC
  19.  Serial.println("cm");
  20.  delay(100);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement