I am working with a Yun board for the first time. I have written a code to change the intensity of an LED according to the output given by an LDR and a PIR motion sensor. The LED should work only when motion is detected by the PIR sensor. But, I have failed to notice the change in intensity of the LED.
I have observed the change when I dumped a simple Intensity variation code but the variation is not being observed when I am using an LDR and a PIR. Can you please help me out??
I am attaching my code hereā€¦

doubt.pdf (116 KB)

Hi, please post your sketch in your reply using code tags. I can't open your pdf, my phone says there is a security problem with it.

Also please post a schematic of your circuit. Hand drawn and scanned/photographed is fine. Or a photo of your circuit as long as it is clear where each wire and component are connected.


x = ledglow (lightPc) ;

So print out x and see what it is.

What do you think this does?

int ledglow (int lightPc)

What ever you think it is, it is not.

What do you think this does?

To the OP, if you expect help on these topics, PLEASE try to adhere to an indenting convention and group functions separated by blank lines.

I give Mike "Kudos" for even attempting to understand code so poorly written you have to first massage it to make any sense of it.

Please do not post PDFs.

The format has two specific functions; to concisely encode information to be accurately and repeatably rendered on a piece of paper, and to obscure the source information; that is, to make it as difficult as possible to re-use or examine in detail.

Unless either or both of these are your intention, it is a useless format and Web browsers do not always naturally render it. If you have code, please include it in the text using "code" tags (generated by the little "code" icon - the scroll with brackets). Reviewers object to having to perform additional processes to see it. If it is an image, use the "Attachments and other options" to upload it to the site if it is not directly linkable on a non-obscuring website.

And, when posting code, at least attempt to format it legibly using the "Auto Format" tool in the IDE (albeit unfortunately does not work on arrays).

I have tried using the function you suggested and it worked. Thank you