From 091f0c084f44ba6ce1656cdc73ab034abc881620 Mon Sep 17 00:00:00 2001 From: Luca Tringali Date: Mon, 11 Mar 2019 23:02:50 +0100 Subject: Rinomina file --- dissolvenza-led-distanza-ultrasuoni.ino | 41 --------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 dissolvenza-led-distanza-ultrasuoni.ino (limited to 'dissolvenza-led-distanza-ultrasuoni.ino') 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); -} -- cgit v1.1