Single Pulse Help.

Hey arduino community,

Edited:

This exactly what i'm trying to do:

I have an LDR and up/downCounter circuit. For now, I want the counter to count up everytime the LDR is activated. In other words, every time the LDR is covered with my hand, it will sent a single pulse to my counter circuit.

Diagram: http://www.flickr.com/photos/64214999@N05/6305469215/

Counter Circuit (* ignore other connection as this was take from an old project): http://www.flickr.com/photos/64214999@N05/6276037343/in/photostream/

LDR Circuit: http://farm7.static.flickr.com/6229/6276037577_ddef4f15be.jpg

I start with this code... but i'm new so mine horrible coding.

int up = 9;
int ldr = 8;


void setup() { 
pinMode(up, OUTPUT);    
pinMode(ldr, INPUT);
}


void loop() {


if (ldr == HIGH){
digitalWrite(up, HIGH);  
}   

else if (ldr == LOW){
digitalWrite(up, LOW); 
}


}

Thanks, Anura XD

I have a up/down counter

You need to describe this in more detail. Is this somehow connected to an Arduino?

i want it to sent a single pulse like on the digital trainers.

Like so?

Serial.print("pulse");

What is "it" what should send this pulse? Where should it send it to? How long should the pulse last?

I wondering if can give me some advice?

Yes.

You may need Serial.print("-pulse"); if you want a negative-going pulse

I have edited my question. Thanks anyway.

if (ldr == HIGH){

You have given "ldr" the value 8. That is never going to equal HIGH (aka 1)

You're missing a "digitalRead (ldr)"

But i have to define the ldr pin right?

I just added the "digitalRead (ldr)" to the "void loop" but it does no work.

I just added the "digitalRead (ldr)" to the "void loop" but it does no work.

Yes, but you have to check what the return value is. You did that, right?

I managed to tweak the code by using "analogRead".

Thanks anyway.