Page 45 - Trabajo final
P. 45

void loop()

                  {



                    digitalWrite(trig, HIGH);

                    delay(1);

                    digitalWrite(trig, LOW);

                    t= pulseIn(echo, HIGH);

                    d= t/58.2;




                    Serial.println("cm");

                    Serial.print(d);

                    delay(500);



                    if (d <150)



                      {

                     digitalWrite (ld1, HIGH);

                      Serial.println("cm");

                      Serial.print(d);


                      delay(500);



                    }



                     if (d<100)



                      {

                     digitalWrite (ld2, HIGH);

                     Serial.println("cm");
   40   41   42   43   44   45   46   47   48   49   50