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.

Automatic Light Sensor With Counter

Status
Not open for further replies.

Rushdiey

Junior Member level 2
Joined
Jan 10, 2013
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,419
How to make c programming coding.. when ldr goes dark it will count something.
I hope someone can share it

#include <reg51.h>
#include <stdio.h>
sbit LDR=P0^7;
long int count;
long int i;

void main()
{
while(1)
{
if(LDR==1)
count++;

else
{
count--;
}
}
}

this is my example. but not work
 

Why u put else condition ?
How u confirm ur code not working ?
Is ur H/w 100% ok ?
Explain ur application ?
 

I want to put it at door.. when someone coming i will count people.
for else i just randomly put
 

I want to put it at door.. when someone coming i will count people.
for else i just randomly put
ip_pin => ur pin
count =>variable
limit =>max count limit
while
{
if(ip_pin==0)
{
count++;
}
delay(100);
if(count>limit)
{
count=0;
}
}
 

If two door then use count++ IN, count--OUT. u can use while also instead of if for pin sensing
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top