summaryrefslogtreecommitdiff
path: root/dissolvenza-led-distanza-ultrasuoni.ino
diff options
context:
space:
mode:
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);
-}