Posts

Showing posts from May, 2025

ESP 8266- External LED Blink

Image
  #define LED D0             void setup()   { pinMode(LED, OUTPUT);     } void loop() { digitalWrite(LED, HIGH);                         delay(1000);             digitalWrite(LED, LOW); delay(1000); }

ESP 8266- Servo Motor Interfacing

Image
#include <Servo.h> #define servopin D0 Servo myservo;                  // create servo object to control a servo void setup()  {   myservo.attach(servopin,400,2500);  // attaches the servo on D0 }   void loop() {   int pos;     for (pos = 0; pos <= 180; pos += 1) {  // goes from 0 degrees to 180 degrees     // in steps of 1 degree     myservo.write(pos);  // tell servo to go to position in variable 'pos'     delay(15);           // waits 15ms for the servo to reach the position   }   for (pos = 180; pos >= 0; pos -= 1) {  // goes from 180 degrees to 0 degrees     myservo.write(pos);                  // tell servo...

ESP 8266- Ultrasonic Sensor Interfacing

Image
  #define trigPin D0 #define echoPin D1 long duration; int distance;   void setup() {   Serial.begin(9600); // Starts the serial communication   pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output   pinMode(echoPin, INPUT); // Sets the echoPin as an Input }   void loop() {   // Clears the trigPin   digitalWrite(trigPin, LOW);   delayMicroseconds(2);   // Sets the trigPin on HIGH state for 10 micro seconds   digitalWrite(trigPin, HIGH);   delayMicroseconds(10);   digitalWrite(trigPin, LOW);     // Reads the echoPin, returns the sound wave travel time in microseconds   duration = pulseIn(echoPin, HIGH);     // Calculate the distance   distance = duration * 0.034/2;   // 0.034 means velocity of sound in cm/us         // Prints the distance on the Serial Monitor   Serial.print("Distance: "); ...

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 }