LDR Only have 1 value

I try to use LDR and 5v laser to count person come in and go out then if in room have person turn light and some electronic on , Now the problem I try it on breadboard but it not work I try print value but it stuck at 18 and don’t change (try flashlight and laser but don’t change too) then I try only print value code LDR work normally value change like it should be , I think it should have a problem with code (I’m so weak coding ._.) Can some one help me with coding please. (not sure this problem on code or not)
Ps.use LED instead light and electronic
Ps2.sorry for my weak english skill
Ps3.my midterm project (Freshman)

const int infraredIn = A4; //firstLDR
const int infraredOut = A0; //secondLDR
const int LED = 2;
int Invalue;
int Outvalue;
int a=0;
int b=0;
int person=0;

void setup() {
Serial.begin(9600);
pinMode(infraredIn,INPUT);
pinMode(infraredOut,INPUT);
pinMode(LED,OUTPUT);
}

void loop() {
Invalue = analogRead(infraredIn);
Outvalue=analogRead(infraredOut);
if (Invalue < 300){
    a=1; 
}

if (Outvalue < 300){
    b=1;
}

if(a > b){
 person ++;
 delay(1000);
} else if (b > a){
   person--;
   delay(1000);
}
if(person>=1){
 digitalWrite(LED,HIGH);}
 else{digitalWrite(LED,LOW);
 person=0;
 }
Serial.println(infraredIn);
Serial.println(infraredOut);
Serial.println(person);
Serial.println(a);
Serial.println(b);
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

Your post has two links that are tagged as images. The images are not loading. The links are to a site that does not appear to be functioning correctly. The site appears to be spam.

Was that your intent? To post spam?

I try to use LDR and 5v laser to

A schematic would be very useful.

pinMode(infraredOut,INPUT);

Why does a pin number stored in a variable with Out in the name have a type of INPUT?

Invalue = analogRead(infraredIn);
Outvalue=analogRead(infraredOut);

Since these pin numbers are used in an analog mode, setting the digital nature of the pin was pointless.

if(a > b){
 person ++;
 delay(1000);
} else if (b > a){
   person--;
   delay(1000);
}

How many people can come and go while you are twiddling your thumbs?

if(person>=1){
 digitalWrite(LED,HIGH);}
 else{digitalWrite(LED,LOW);
 person=0;
 }

I strongly recommend that you get your space and enter keys fixed. This code looks like crap.

if (person >= 1)
{
   digitalWrite(LED, HIGH);
}
else
{
   digitalWrite(LED, LOW);
   person=0;
}

Way easier to read!

Serial.println(infraredIn);
Serial.println(infraredOut);

Why is it important to know the pin numbers? Wouldn’t printing the VALUES read from the pins make more sense?

Wouldn’t printing some useful information before the value make sense?

if (Invalue < 300){
    a=1;
}

And, it the value is greater than, or equal to, 300, leave a whatever it was? Does that make sense?

The same applies to the b manipulation code.

Your post has two links that are tagged as images. The images are not loading. The links are to a site that does not appear to be functioning correctly. The site appears to be spam.

Was that your intent? To post spam?

Sorry about that I just post my breadboard picture by using picture deposit web

Why does a pin number stored in a variable with Out in the name have a type of INPUT?

I use 2 laser and 2 LDR check person come in or go out

Why is it important to know the pin numbers? Wouldn't printing the VALUES read from the pins make more sense?

Wouldn't printing some useful information before the value make sense?
that is my main problem I use mistake code thank for remind this thing Orz

And, it the value is greater than, or equal to, 300, leave a whatever it was? Does that make sense?
I try it on read value only code and if I come across laser value up to 300 and more but if only laser this value less than 300

Now only LDR 1 value solve because I use mistake code I read pin number instead Orz thank you PaulS

petchl:
Sorry about that I just post my breadboard picture by using picture deposit web

• Click Reply. It's at the bottom of the posts.

• Click Attachments and other options

• Click Browse

• Select the images

• Click Open

• Click Post