I working on ldr using laser based security project . with the help of node mcu . i want to do that if any unwanted access is attempted then it gives notification on my phone
but i facing issue with the code , it gives error that is -
> ldrPin' was not declared in this scope
but i already declared it before . so anyone please help me :-
hear the code down below -
#include <ESP8266WiFi.h>
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <BlynkSimpleEsp8266.h>
char auth[] = "fb607aaa4be245ababdba1abd1dd0f70";
/* WiFi credentials */
char ssid[] = "POCO F1";
char pass[] = "";
/* HC-SR501 Motion Detector */
#define ledPin 5
#define ldrpin A0 // Input for HC-S501
int ldrValue; // Place to store read PIR Value
void setup()
{
Serial.begin(115200);
delay(10);
Blynk.begin(auth, ssid, pass);
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
digitalWrite(ledPin, LOW);
}
void loop()
{
getldrValue();
Blynk.run();
}
/***************************************************
* Get ldr data
**************************************************/
void getldrValue(void)
{
ldrValue = digitalRead(ldrpin);
if (ldrValue)
{
Serial.println("==> Motion detected");
Blynk.notify("T==> Motion detected");
}
digitalWrite(ledPin, ldrValue);
}
Now I am facing problem with LDR sensor . My LDR sensor does not read any value . I want to do that if LDR sensor value is less than 600 then it give me a notification on my phone through blynk app . here is the full code … please help me … i need your help …
#include <ESP8266WiFi.h>
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <BlynkSimpleEsp8266.h>
char auth[] = "f8f7db19db7e4f93a74651591130405f";
/* WiFi credentials */
char ssid[] = "POCO F1";
char pass[] = "";
/* HC-SR501 Motion Detector */
#define ledPin 5
#define ldrPin A0 // Input for HC-S501
int ldrValue; // Place to store read ldr Value
void setup()
{
Serial.begin(115200);
delay(10);
Blynk.begin(auth, ssid, pass);
pinMode(ledPin, OUTPUT);
// pinMode(ldrPin, INPUT);
digitalWrite(ledPin, LOW);
}
void loop()
{
getldrValue();
Blynk.run();
}
/***************************************************
* Get ldr data
**************************************************/
void getldrValue(void)
{
ldrValue = digitalRead(A0);
if (ldrValue <=600) //IF LDR VALUE IS LESS THEN 600 THEN IT GIVES NOTIFICATION ON MY PHONE
{
Serial.println("==> Motion detected");
digitalWrite(ledPin, HIGH);
Serial.print(ldrValue);
Serial.println("LDR is DARK, LED is ON");
// Blynk.notify("T==> Motion detected");
}
else {
digitalWrite(ledPin, LOW);
Serial.println("LED is OFF");
}
// analogWrite(ldrPin);
digitalWrite(ledPin,ldrPin);
}
Please properly format posted code as per the Welcome Topic… I fixed your last post.
Generally we try to assist users about learning Blynk and finding documentation. Aside from a suggestion here or there… fixing or writing your code is for you to learn to do.
Google for some LDR examples in the wild web and break them down to understand how they work. then you can add in Blynk to act as a controller/GUI