Posts

Showing posts with the label ESP8266 (NodeMCU)

ESP8266- Proximity Sensor Interfacing

Image
  #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);      } }

ESP8266- Inbuilt LED Blink

Image
 void setup() {   // initialize digital pin LED_BUILTIN as an output.   pinMode(LED_BUILTIN, OUTPUT); } // the loop function runs over and over again forever void loop() {   digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)   delay(1000);                       // wait for a second   digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW   delay(1000);                       // wait for a second }