![Automated Lighting, an IoT and ML project built by devanshunagmode - Google Chrome 24-11-2024 12_26_08|690x366]
i am facing these kind for problem for an automayed light system
thes are my codes
// Set up chart library and configuration for visualization
setChartLibrary(“google-chart”);
setChartTitle(“Light Intensity vs. Time”);
setChartType(“lineGraph”);
setAxisName(“Time”, “Light Intensity”);
plotChart(“time_stamp”, “photodiode”); // Plot data from A0 (photodiode)
// Define the light intensity threshold
const lightThreshold = 300;
// Monitor light intensity and control the LED
setInterval(() => {
analogRead(“photodiode”, (response) => {
if (response.success === “1”) {
const lightIntensity = parseInt(response.value);
console.log(Light Intensity: ${lightIntensity}
);
// Control LED based on light intensity
if (lightIntensity < lightThreshold) {
digitalWrite("led", "HIGH"); // Turn ON LED if room is dark
console.log("LED turned ON: Room is dark.");
} else {
digitalWrite("led", "LOW"); // Turn OFF LED if room is bright
console.log("LED turned OFF: Room is bright.");
}
} else {
console.error("Error reading light intensity data from A0.");
}
});
}, 5000); // Check every 5 seconds
(“A0” - photodiode and digital pin1 = led)
please help me to resolve this problem