I have the LDR connected to A0. I want to read the value of LDR’s output and use it in my code for further processing. In my product pin configuration, I call this pin as “light”, without the quotes
For now, I only know to use this in plotChart function. How can I assign this to a javascript variable and toggle an LED based on the value of the LDR output?
Somthing like this:
setChartLibrary(‘google-chart’);
setChartType(‘lineGraph’);
setChartTitle(‘Light Intensity’);
setAnimation(true);
plotChart(‘time_stamp’, ‘light’);
// Copy the analog reading into a variable
light_variable = light // This needs to be modified
if (light_variable > 512) {
singleButton({name:“Led On”, action:“digitalWrite”,
pin:“0”, value:“HIGH”,bgcolor:“green”,
shape:“rectangle”,align:“left”,“text_color”:“white” });
} else {
singleButton({name:“Led Off”, action:“digitalWrite”,
pin:“0”, value:“LOW”, bgcolor:“red”,
shape:“rectangle”, align:“left”, text_color:“black”});
}