Connect a Sketch

This is a People counter, well hope to be if working.ha.
Lazer across a doorway hitting a LDR.
The 4 digit 7 seg display counting up 1 each time a person breaks the beam. 

As of now i  have a counting sketch from the Sparkfun example. It is counting up 0 to 999 and at the same time i have an LDR reading to the serial monitor and blinking the LED on pin 13. But they are not "interacting". I am trying to get the beam breakes from the LDR to advance the count by 1 every time it is broken.

In the loop function is the mills that was advancing the counting. I have changed it to   displayNumber(counter).  Among other things.But i haven't been successful in having the LDR advance the count. The sketch is still missing some "stuff".

What could i change to have the counter advance by 1 every time the lazer beam is broken?   

Thanks
W

/*
6-13-2011
Spark Fun Electronics 2011
Nathan Seidle

This code is public domain but you buy me a beer if you use this and we meet
someday (Beerware license).

4 digit 7 segment display:
http://www.sparkfun.com/products/9483
Datasheet:
http://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AR6B-35.pdf

This is an example of how to drive a 7 segment LED display from an ATmega
without the use of current limiting resistors. This technique is very common
but requires some knowledge of electronics - you do run the risk of dumping
too much current through the segments and burning out parts of the display.
If you use the stock code you should be ok, but be careful editing the
brightness values.

This code should work with all colors (red, blue, yellow, green) but the
brightness will vary from one color to the next because the forward voltage
drop of each color is different. This code was written and calibrated for the
red color.

This code will work with most Arduinos but you may want to re-route some of
the pins.

7 segments
4 digits
1 colon
=
12 pins required for full control

*/
#define ldrPin A2    // pin used for input (analog)
  
int digit1 = 11; //PWM Display pin 1
int digit2 = 10; //PWM Display pin 2
int digit3 = 9; //PWM Display pin 6
int digit4 = 6; //PWM Display pin 8

//Pin mapping from Arduino to the ATmega DIP28 if you need it
//http://www.arduino.cc/en/Hacking/PinMapping

//int ldrPin = A2;
int segA = A1; //Display pin 14
int segB = 3; //Display pin 16
int segC = 4; //Display pin 13
int segD = 5; //Display pin 3
int segE = A0; //Display pin 5
int segF = 7; //Display pin 11
int segG = 8; //Display pin 15
int ldr_pinValue;
int counter;
int currState;
int then;
//int ldrpread;
//int digit[4];
//int leftover;


int LDR = A2;                                //analog pin to which LDR is connected, here we set it to 0 so it means A0
int LDRValue = 0;                    //that’s a variable to store LDR values
int light_sensitivity = 500;  //This is the approx value of light surrounding your LDR




//int digit_to_show = 0;

int ldr_Pin = 0;  // LED status (0 = low, 1 = high)
int inVal = 0;    // variable used to store state of input

int switchOn = 725;   // value at which we switch LED on
int switchOff = 550;  // value at which we switch LED off

void setup() {
 
 
    {
    Serial.begin(9600);            //start the serial monitor with 9600 buad
    pinMode(13, OUTPUT);     //we mostly use13 because there is already a built in yellow LED in arduino which shows output when 13 pin is enabled
  }
 
 

  pinMode(ldr_Pin, INPUT ); 
  pinMode(segA, OUTPUT);
  pinMode(segB, OUTPUT);
  pinMode(segC, OUTPUT);
  pinMode(segD, OUTPUT);
  pinMode(segE, OUTPUT);
  pinMode(segF, OUTPUT);
  pinMode(segG, OUTPUT);

  pinMode(digit1, OUTPUT);
  pinMode(digit2, OUTPUT);
  pinMode(digit3, OUTPUT);
  pinMode(digit4, OUTPUT);
 
  pinMode(13, OUTPUT);

}

void loop(){


{
    LDRValue = analogRead(LDR);          //reads the ldr’s value through LDR which we have set to Analog input 0 “A0″
    Serial.println(LDRValue);                  //prints the LDR values to serial monitor
    delay(5);                                                //This is the speed by which LDR sends value to arduino

    if (LDRValue < light_sensitivity)
      {
        digitalWrite(13, HIGH);
      }
    else
      {
        digitalWrite(13, LOW);

{
   if (currState() >  300) then
   
    currState = HIGH
   }
else
    currState = LOW
//endif
if currState != prevState and currState == LOW then // LOW or HIGH depending on the circuit
    counter++
    prevState = currState
endif




  
  //long startTime = millis();


  displayNumber(counter);
 
  //while( (millis() - startTime) < 2000) {
  //displayNumber(1217);
  //}
  //delay(1000); 
  }


//Given a number, we display 10:22
//After running through the 4 numbers, the display is left turned off

//Display brightness
//Each digit is on for a certain amount of microseconds
//Then it is off until we have reached a total of 20ms for the function call
//Let's assume each digit is on for 1000us
//Each digit is on for 1ms, there are 4 digits, so the display is off for 16ms.
//That's a ratio of 1ms to 16ms or 6.25% on time (PWM).
//Let's define a variable called brightness that varies from:
//5000 blindingly bright (15.7mA current draw per digit)
//2000 shockingly bright (11.4mA current draw per digit)
//1000 pretty bright (5.9mA)
//500 normal (3mA)
//200 dim but readable (1.4mA)
//50 dim but readable (0.56mA)
//5 dim but readable (0.31mA)
//1 dim but readable in dark (0.28mA)

void displayNumber(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

  long beginTime = millis();

  for(int digit = 4 ; digit > 0 ; digit--) {

    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
      digitalWrite(digit1, DIGIT_ON);
      break;
    case 2:
      digitalWrite(digit2, DIGIT_ON);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      break;
    }

    //Turn on the right segments for this digit
    lightNumber(toDisplay % 10);
    toDisplay /= 10;

    delayMicroseconds(DISPLAY_BRIGHTNESS);
    //Display digit for fraction of a second (1us to 5000us, 500 is pretty good)

    //Turn off all segments
    lightNumber(10);

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
  }

  while( (millis() - beginTime) < 10) ;
  //Wait for 20ms to pass before we paint the display again
}

//Given a number, turns on those segments
//If number == 10, then turn off number
void lightNumber(int numberToDisplay) {

#define SEGMENT_ON  LOW
#define SEGMENT_OFF HIGH

  switch (numberToDisplay){

  case 0:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 1:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 2:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 3:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 4:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 5:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 6:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 7:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 8:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 9:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 10:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;
  }
}


sort by: active | newest | oldest
frollard5 years ago
A couple things;

You define LDRpin about 3 times at the start...

stick to one to make sure its right.  You define it as a2 and a0;

...and you left off half your program...
//*****************
if (currState() >  300) then
  
    currState = HIGH
   }
else
    currState = LOW
//endif
if currState != prevState and currState == LOW then // LOW or HIGH depending on the circuit
    counter++
    prevState = currState
endif
//***********************
What does that even do?!  You didn't include a function currState();
You're calling a function called currState() to find the value...then you're trying to WRITE to that value with currState = HIGH or LOW.  You can't tell a function what to return to you from outside :)

How do you have your LDR wired up?  Does the value go UP with brightness or DOWN with brightness?


I wrote my own version really quick, hope it makes sense.

/*
6-13-2011
Spark Fun Electronics 2011
Nathan Seidle

This code is public domain but you buy me a beer if you use this and we meet
someday (Beerware license).

4 digit 7 segment display:
http://www.sparkfun.com/products/9483
Datasheet:
http://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AR6B-35.pdf

This is an example of how to drive a 7 segment LED display from an ATmega
without the use of current limiting resistors. This technique is very common
but requires some knowledge of electronics - you do run the risk of dumping
too much current through the segments and burning out parts of the display.
If you use the stock code you should be ok, but be careful editing the
brightness values.

This code should work with all colors (red, blue, yellow, green) but the
brightness will vary from one color to the next because the forward voltage
drop of each color is different. This code was written and calibrated for the
red color.

This code will work with most Arduinos but you may want to re-route some of
the pins.

7 segments
4 digits
1 colon
=
12 pins required for full control

*/

/*
People counter sketch modified by Frollard on October 2 2012
checks an analog input, when it reaches a threshhold it increments a counter, and won't
increment that counter again until another lower reset threshhold has been hit.
*/

//global:
int peopleCount = 0;          //total count of people, init zero
bool currentState = 1; //are we even listening for new hits?
#define LDRPin A2 //pin to read LDR
#define ledPin 13 //output led pin
int light_sensitivity = 500;  //This is the approx value of light surrounding your LDR
int countTrigger = light_sensitivity + 200;  //value the LDR exceeds to count someone
int resetTrigger = light_sensitivity + 50; //value at which to start counting again
//it wouldn't be a bad idea in void loop to keep averaging the current value and
//adjusting all these values in case the lighting changes.

//**********digit declares
int segA = A1; //Display pin 14
int segB = 3; //Display pin 16
int segC = 4; //Display pin 13
int segD = 5; //Display pin 3
int segE = A0; //Display pin 5
int segF = 7; //Display pin 11
int segG = 8; //Display pin 15

int digit1 = 11; //PWM Display pin 1
int digit2 = 10; //PWM Display pin 2
int digit3 = 9; //PWM Display pin 6
int digit4 = 6; //PWM Display pin 8
//***********end digit declares

void setup() {
  pinMode(LDRPin, INPUT);       // declare the LDR as an INPUT
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT

  pinMode(segA, OUTPUT);
  pinMode(segB, OUTPUT);
  pinMode(segC, OUTPUT);
  pinMode(segD, OUTPUT);
  pinMode(segE, OUTPUT);
  pinMode(segF, OUTPUT);
  pinMode(segG, OUTPUT);

  pinMode(digit1, OUTPUT);
  pinMode(digit2, OUTPUT);
  pinMode(digit3, OUTPUT);
  pinMode(digit4, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
checkInput(); //reads the ldr and counts if necessary.
displayNumber(peopleCount);

}
//******Averages the LDR reading, then acts upon it, counting, and toggling the led.
void checkInput()
{
  int LDRValue = 0;
  //remove noise by taking 5 readings then averaging
  for (int i = 0; i<5; i++){
    delay(1); //may not be necessary but analogRead() can be messy when next to pwm
    LDRValue += analogRead(LDRPin);
  }
  LDRValue = LDRValue / 5;

 
  if (currentState == 1) //actively looking for a person
  { //if true, act on the LDR value to attempt to count
    if (LDRValue >= countTrigger){ //if ldr goes above trigger we found someone
    currentState = 0; //stop listening for new counts until it gets bright again
    peopleCount++; //increment the count
    digitalWrite(ledPin,HIGH); //led on

    }
  }
  else //currentstate was false, don't check for people, check for reset
  {
    if (LDRValue <= resetTrigger){ //if value was below the reset threshhold
     currentState = 1; //start listening again
    digitalWrite(ledPin,LOW); //led off
    }
   
  }
 
}

//Given a number, we display 10:22
//After running through the 4 numbers, the display is left turned off

//Display brightness
//Each digit is on for a certain amount of microseconds
//Then it is off until we have reached a total of 20ms for the function call
//Let's assume each digit is on for 1000us
//Each digit is on for 1ms, there are 4 digits, so the display is off for 16ms.
//That's a ratio of 1ms to 16ms or 6.25% on time (PWM).
//Let's define a variable called brightness that varies from:
//5000 blindingly bright (15.7mA current draw per digit)
//2000 shockingly bright (11.4mA current draw per digit)
//1000 pretty bright (5.9mA)
//500 normal (3mA)
//200 dim but readable (1.4mA)
//50 dim but readable (0.56mA)
//5 dim but readable (0.31mA)
//1 dim but readable in dark (0.28mA)

void displayNumber(int toDisplay) {
#define DISPLAY_BRIGHTNESS  500

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

  long beginTime = millis();

  for(int digit = 4 ; digit > 0 ; digit--) {

    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
      digitalWrite(digit1, DIGIT_ON);
      break;
    case 2:
      digitalWrite(digit2, DIGIT_ON);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      break;
    }

    //Turn on the right segments for this digit
    lightNumber(toDisplay % 10);
    toDisplay /= 10;

    delayMicroseconds(DISPLAY_BRIGHTNESS);
    //Display digit for fraction of a second (1us to 5000us, 500 is pretty good)

    //Turn off all segments
    lightNumber(10);

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
  }

  while( (millis() - beginTime) < 10) ;
  //Wait for 20ms to pass before we paint the display again
}

//Given a number, turns on those segments
//If number == 10, then turn off number
void lightNumber(int numberToDisplay) {

#define SEGMENT_ON  LOW
#define SEGMENT_OFF HIGH

  switch (numberToDisplay){

  case 0:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 1:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 2:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 3:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 4:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 5:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 6:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 7:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 8:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 9:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 10:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;
  }
}

WWC (author)  frollard5 years ago
As you can see my coding skill do not even make it up to the verry bad category. Its only about the second time i have tried to make a big change in coding other than changing a delay ect.

I will try this sketch you provided so quickly.
frollard WWC5 years ago
Keep in mind, I have no idea what the Spark Fun thing does - I presume it works and it looks okay.

I hooked this up to my arduino with a variable 10k resistor and it gave me a count every time I got about 3/4 up...and didn't count again until I had returned past the middle ground; it all depends on how you have the LDR wired up, in which case you might need to change the if statement in checkInput() to trigger BELOW a certain value, and reset ABOVE...changing the 'room light intensity' and sensitivities likewise.
WWC (author)  frollard5 years ago
WORKING. WORKING. WORKING

You must of been coding for some years to be able to whip that sketch out like that.
I am impressed and thankful.

You will receive the credit due in my ible also Best answer.


If i wanted to turn the first zeros off until the count reaches that point how is that written, if you can understand my description.

Thank You
Wayne
frollard WWC5 years ago
Awesome!

If you want to blank the display for unnecessary zeroes, change out the select case here:

//Turn on a digit for a short amount of time
switch(digit) {
case 1:
if (toDisplay>999) digitalWrite(digit1, DIGIT_ON);
break;
case 2:
if (toDisplay>99) digitalWrite(digit2, DIGIT_ON);
break;
case 3:
if (toDisplay>9) digitalWrite(digit3, DIGIT_ON);
break;
case 4:
digitalWrite(digit4, DIGIT_ON);
break;
}
//mod assumes that digits are in the order of 1 2 3 4, its what the program makes it look like it should be, but let me know if it isn't. :)
WWC (author)  frollard5 years ago
Will,
I am rehooking everything back up now.
i think i got about the trigger numbers, depends on ambient light some also i believe.

Thanks
W
frollard WWC5 years ago
Very lastly, if you want to be REALLY clever, you can pulse the laser with the arduino, and then constantly take on/off measurements from the ldr to be able to ignore room lighting. For a person to be counted, the difference between laser and no laser drops to zero, while the no-person shows a vast difference between laser and no laser.

Alternately, you can blink an led at say 60hZ on the arduino, and put a reflector on the wall across from it, all the electronics are in one place.

Just keep measuring 'led on LDR value' and 'led off LDR value' and subtracting them, if the difference drops below a threshold, then count, with the same lockout rules that don't start counting again until you see a larger difference again (beam detected)
iceng5 years ago
WWC (author)  iceng5 years ago
Interesting You used Arduino?
iceng WWC5 years ago
Sorry,  but it's a one-time burn PIC with good old machine code.
Shy-Anne iceng5 years ago
who are you and are you new
do you know the answer to my question!!!!!!!!!!!!!!
iceng Shy-Anne5 years ago
See my page

I feel new every am
iceng Shy-Anne5 years ago
See my page

I feel new every am
Shy-Anne iceng5 years ago
who cares if it's a one-time burn pic
iceng Shy-Anne5 years ago
Does it matter if someone cares
rickharris5 years ago
Is this a complete project or a question??

If complete then make it into an instructable

If a question then please be clearer.
i would have to agree with you rickharris!lol
WWC (author)  rickharris5 years ago
rickharris thanks for your interest.

Ok i will try and ask it a little differently. Its is not completed only for this last problem i am working on. Then an ible to follow.

This is a question, How do i make the 4 digit 7 seg display count up, 1,2,3,ect from a trigger from the LDR? The LDR is triggered from a lazer that is pointed at it, well when the beam is broken

I do not know the proper coding to connect the two actions, the counting and the triggering. I am asking for a solution to connect the two.

If more info is needed ask again and i will provide what i can