summaryrefslogtreecommitdiff
path: root/dissolvenza-led-distanza-ultrasuoni.ino
diff options
context:
space:
mode:
authorLuca Tringali <tringalinvent@libero.it>2019-03-11 23:02:50 +0100
committerLuca Tringali <tringalinvent@libero.it>2019-03-11 23:02:50 +0100
commit091f0c084f44ba6ce1656cdc73ab034abc881620 (patch)
treeef68cdf5fb2b033a42d2c94bbc656b047deb17c0 /dissolvenza-led-distanza-ultrasuoni.ino
parent299ee1066f15506da34beeba6e90a44891780734 (diff)
Rinomina file
Diffstat (limited to 'dissolvenza-led-distanza-ultrasuoni.ino')
-rw-r--r--dissolvenza-led-distanza-ultrasuoni.ino41
1 files changed, 0 insertions, 41 deletions
diff --git a/dissolvenza-led-distanza-ultrasuoni.ino b/dissolvenza-led-distanza-ultrasuoni.ino
deleted file mode 100644
index a7be908..0000000
--- a/dissolvenza-led-distanza-ultrasuoni.ino
+++ /dev/null
@@ -1,41 +0,0 @@
-//HC RS04 Sensore ultrasuoni
-const int triggerPort = 9;
-const int echoPort = 10;
-const int led = 3;
-
-void setup() {
-
-pinMode(triggerPort, OUTPUT);
-pinMode(echoPort, INPUT);
-pinMode(led, OUTPUT);
-Serial.begin(9600);
-}
-
-void loop() {
-
-
-digitalWrite( triggerPort, LOW );
-//invia un impulso di 10microsec su trigger
-digitalWrite( triggerPort, HIGH );
-delayMicroseconds( 10 );
-digitalWrite( triggerPort, LOW );
-
-long durata = pulseIn( echoPort, HIGH );
-
-long distanza = 0.034 * durata / 2;
-
-Serial.print("distanza: ");
-
-//durata in millisecondi
-if( durata > 38000 ){
-Serial.println("Fuori portata ");
-}
-else{
-Serial.print(distanza);
-Serial.println(" cm");
-int fadeValue = map(durata, 0, 38000, 0, 255)
-analogWrite(led, fadeValue);
-}
-
-delay(1000);
-}