Sep 8, 2013 #1 R 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--; } } } Click to expand... this is my example. but not work
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--; } } } Click to expand... this is my example. but not work
Sep 8, 2013 #2 Golden Electronics Full Member level 5 Joined May 31, 2013 Messages 308 Helped 50 Reputation 100 Reaction score 47 Trophy points 1,318 Location India Activity points 2,730 Why u put else condition ? How u confirm ur code not working ? Is ur H/w 100% ok ? Explain ur application ?
Why u put else condition ? How u confirm ur code not working ? Is ur H/w 100% ok ? Explain ur application ?
Sep 9, 2013 #3 R 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 I want to put it at door.. when someone coming i will count people. for else i just randomly put
Sep 9, 2013 #4 Golden Electronics Full Member level 5 Joined May 31, 2013 Messages 308 Helped 50 Reputation 100 Reaction score 47 Trophy points 1,318 Location India Activity points 2,730 Rushdiey said: I want to put it at door.. when someone coming i will count people. for else i just randomly put Click to expand... ip_pin => ur pin count =>variable limit =>max count limit while { if(ip_pin==0) { count++; } delay(100); if(count>limit) { count=0; } }
Rushdiey said: I want to put it at door.. when someone coming i will count people. for else i just randomly put Click to expand... ip_pin => ur pin count =>variable limit =>max count limit while { if(ip_pin==0) { count++; } delay(100); if(count>limit) { count=0; } }
Sep 9, 2013 #5 tpetar Advanced Member level 7 Joined Sep 27, 2010 Messages 6,417 Helped 1,713 Reputation 3,456 Reaction score 1,673 Trophy points 1,393 Location Pancevo-Belgrade, Serbia Activity points 37,363 Do you have separate doors one for entry and one for exit ? Best regards, Peter
Sep 9, 2013 #6 Golden Electronics Full Member level 5 Joined May 31, 2013 Messages 308 Helped 50 Reputation 100 Reaction score 47 Trophy points 1,318 Location India Activity points 2,730 If two door then use count++ IN, count--OUT. u can use while also instead of if for pin sensing