Single Pulse Help.

Hey arduino community,


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.


Counter Circuit (* ignore other connection as this was take from an old project):

LDR Circuit:

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); 


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?


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?


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.