Pages: [1]   Go Down
Author Topic: Single Pulse Help.  (Read 824 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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  smiley-lol
« Last Edit: November 02, 2011, 08:31:01 am by anura92 » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 654
Posts: 50931
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have edited my question. Thanks anyway.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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)"
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But i have to define the ldr pin right?

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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




Thanks anyway.
Logged

Pages: [1]   Go Up
Jump to: