martes, julio 05, 2016

E18-D80NK Infrared Distance Ranging Sensor


/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

E18-D80NK Infrared Distance Ranging Sensor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/

int sensor=2;

void setup()  {

 Serial.begin(9600); //Start serial communication boud rate at 9600
 pinMode(sensor,INPUT); //Pin 2 as signal input - yellow

}
void loop()  {
 while(1)  {
   delay(500);
   if(digitalRead(sensor)==LOW)  {
    // If no signal print collision detected
     Serial.println("Collision Detected.");
   }
   else  {
     // If signal detected print collision detected
     Serial.println("No Collision Detected.");
   }
 }
}

No hay comentarios.: