Created
March 11, 2022 09:43
-
-
Save sebadima/65897569ffbb6807346600031611dbf6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Libreria Open Source disponibile su: | |
https://playground.arduino.cc/Code/NewPing | |
*/ | |
#include | |
#define PIN_TRASMISSIONE 11 | |
#define PIN_RICEZIONE 12 | |
#define DISTANZA_MAX 200 | |
// Settiamo i pin di Arduino e la distanza massima | |
NewPing sonar(PIN_TRASMISSIONE, PIN_RICEZIONE, DISTANZA_MAX); | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
delay(50); | |
unsigned int distanza = sonar.ping_cm(); | |
Serial.print(distanza); | |
Serial.println(" cm"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment