+ Post New Thread
Results 1 to 6 of 6
  1. #1
    Junior Member level 2
    Points: 708, Level: 5

    Join Date
    Jan 2013
    Posts
    24
    Helped
    0 / 0
    Points
    708
    Level
    5

    Automatic Light Sensor With Counter

    How to make c programming coding.. when ldr goes dark it will count something.
    I hope someone can share it

    #include
    #include
    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

    •   AltAdvertisment

        
       

  2. #2
    Full Member level 5
    Points: 1,841, Level: 9
    Golden Electronics's Avatar
    Join Date
    May 2013
    Location
    India
    Posts
    309
    Helped
    49 / 49
    Points
    1,841
    Level
    9
    Blog Entries
    1

    Re: Automatic Light Sensor With Counter

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



    •   AltAdvertisment

        
       

  3. #3
    Junior Member level 2
    Points: 708, Level: 5

    Join Date
    Jan 2013
    Posts
    24
    Helped
    0 / 0
    Points
    708
    Level
    5

    Re: Automatic Light Sensor With Counter

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



    •   AltAdvertisment

        
       

  4. #4
    Full Member level 5
    Points: 1,841, Level: 9
    Golden Electronics's Avatar
    Join Date
    May 2013
    Location
    India
    Posts
    309
    Helped
    49 / 49
    Points
    1,841
    Level
    9
    Blog Entries
    1

    Re: Automatic Light Sensor With Counter

    Quote Originally Posted by Rushdiey View Post
    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;
    }
    }



  5. #5
    Advanced Member level 5
    Points: 33,525, Level: 44
    Achievements:
    Created Album pictures Created Blog entry 7 years registered
    tpetar's Avatar
    Join Date
    Sep 2010
    Location
    Pancevo-Belgrade, Serbia
    Posts
    6,427
    Helped
    1732 / 1732
    Points
    33,525
    Level
    44

    Re: Automatic Light Sensor With Counter

    Do you have separate doors one for entry and one for exit ?


    Best regards,
    Peter
    “Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine.” Nikola Tesla



    •   AltAdvertisment

        
       

  6. #6
    Full Member level 5
    Points: 1,841, Level: 9
    Golden Electronics's Avatar
    Join Date
    May 2013
    Location
    India
    Posts
    309
    Helped
    49 / 49
    Points
    1,841
    Level
    9
    Blog Entries
    1

    Re: Automatic Light Sensor With Counter

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



--[[ ]]--