Hi :)
Can anyone send me a sample of c code to use a Light Sensor (LDR) ?
regards.
Hi :)
Can anyone send me a sample of c code to use a Light Sensor (LDR) ?
regards.
Can you read an analouge
Can you read an analouge port on it? There is your code
yes it have, this is the
yes it have, this is the board:
What I ment was: Can you
What I ment was: Can you write the code that reads an analouge input? If so, just hook up the LDR to it, and read the input. That will be the code you are asking for: It is just an analouge input that you need to read in order to read the LDR
If you are not sure how to hook it up, this might help: https://www.robotshop.com/letsmakerobots/node/1833
an example with LDR
i made this simple code that works
#include <sleep.h>
#include <sound.h>
void main()
{
while(1)
{
if (in_c(0)==1) // if have light
{
sound(2000,100); // beep
}
sleep(200);
}
}
im using an atmega8
Cool… However - I think you
Cool… However - I think you are only reading a digital port there, though I am not sure
Point is; You should get a value out - like a number from 0-255 - not just "on/off"… if that is what you want at least
for now all i want is
for now all i want is on/off
regards