Go Down

Topic: Single Pulse Help. (Read 839 times) previous topic - next topic

anura92

Nov 02, 2011, 01:32 pm Last Edit: Nov 02, 2011, 02:31 pm by anura92 Reason: 1
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.

Code: [Select]

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

PaulS

Quote
I have a up/down counter

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

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

Like so?
Code: [Select]
Serial.print("pulse");
What is "it" what should send this pulse? Where should it send it to? How long should the pulse last?

Quote
I wondering if can give me some advice?

Yes.

AWOL

You may need
Code: [Select]
Serial.print("-pulse"); if you want a negative-going pulse
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

anura92

I have edited my question. Thanks anyway.

AWOL

Code: [Select]
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)"
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

anura92

But i have to define the ldr pin right?

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

AWOL

Quote
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?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

anura92

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




Thanks anyway.

Go Up