Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

prograaming of ldr in c

Status
Not open for further replies.

14dhrumit

Member level 3
Joined
Nov 17, 2012
Messages
61
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Hamilton, Ontario, Canada
Activity points
1,653
i want to on-off my LED according to my LDR ,but i don't get it how to create a program in c for LDR on negative coefficient.
 

Off the top of my head - without being tested and without knowing your compiler or target processor -

Maybe something like...

Code:
#define led = PORTA.0

void main(void);
int adc_val;
    init_adc(1);
    while(1){
        read_adc(1);
        if(adc_val > 500){
            led = 0;
        }
        if(adc_val < 480){
            led = 1;
        }
    }
}
 

I am using 89C52. i am using LDR for such a purpose that as the sun sets, the lights starts glowing slowly as the darkness increases..
 

If you want to control the brightness of the output lamp according to the adc value then you have to use a triac. If you just want to ON/OFF output with adc value then you don't need triac.
 

i am controlling it using a controller(89C52) and i just want to switch ON and OFF my LEDs using LDR. It is something like when the light is there, the LEDs won't glow but as soon as the light fades away the LEDs start glowing... And i want programming for that...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top