ESP8266- Proximity Sensor Interfacing


 




#define proximity D0  // IR obstacle sensor connected to D0

#define buzzer D1    // buzzer connected to D1

int val=0;

void setup()

{

   pinMode(proximity, INPUT); // D0 is set as input port

   pinMode(buzzer, OUTPUT); // D1 is set as output port

}

 

void loop()

{

   val=digitalRead(proximity); //reads the value from D0,either HIGH or LOW

   if (val == LOW)

   {

      digitalWrite(buzzer, HIGH);  

   }

   else

   {

      digitalWrite(buzzer, LOW); 

   }

}




Comments

Popular posts from this blog

Motherboard form factor

System Bus Types, Functions, and Features

ESP 8266- Ultrasonic Sensor Interfacing