Posts

Showing posts from July, 2020

Code for HC-05 Bluetooth Module

Code for HC-05 Bluetooth module with NODEMCU to controll LED void setup() {  pinMode(D0, OUTPUT); Serial.begin(9600);     } void loop() { if (Serial.available()){   char data;   data=Serial.read();   Serial.println(data);   if (data =='o'){     digitalWrite(D0,HIGH);     delay(1000);    }   else if(data =='c'){     digitalWrite(D0,LOW);     delay(1000);   } }    }

LED controll using Blynk App

Code for LED ON/OFF Using blynk app with NODEMCU #define BLYNK_PRINT Serial  #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "36F6Titc54BVme6b1ffrDCU0bAauTvMg"; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "Name"; char pass[] = "Password"; void setup() {   pinMode(D1,OUTPUT);   Serial.begin(9600);   Blynk.begin(auth, ssid, pass); }    BLYNK_WRITE(1)   {     int led = param.asInt();     if(led==1)     digitalWrite(D1,HIGH);     else     digitalWrite(D1,LOW);   } void loop() {   Blynk.run(); }

Code for IR sensor

Code for Counter using IR sensor with NODEMCU int irPin=2; int count=0; boolean state = true; void setup() { Serial.begin(9600); pinMode(irPin, INPUT); } void loop() {      if (!digitalRead(irPin) && state){       count++;       state = false;       Serial.print("Count: ");       Serial.println(count);       delay(100);   }   if (digitalRead(irPin)){      state = true;       delay(100);   } } Code for Object detection using IR sensor with NODEMCU int value; // variable to store value read on digital pin  void setup()  {  pinMode(2, INPUT); // initialize digital pin 2 as an input  pinMode(4, OUTPUT); //for LED as output } void loop()  {  value = digitalRead(2); // read value on pin 2  if(value==1) // if value is 1  {  digitalWrite(4, HIGH);...