Pages: 1 [2]   Go Down
Author Topic: Ping)))  (Read 1664 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where is the code that you are using to get any data from the sensor?

Thats the problem! I don't have that.
Logged

Less is more!

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

If you want answers, it is best not to lock the thread.
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: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm sorry i was just trying something.
Logged

Less is more!

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

http://playground.arduino.cc//Main/InterfacingWithHardware#DistanceSensing
has code to deal with a wide variety of distance measuring sensors.
Logged

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

Tanks,

But is it possible to add 1 to the totalcount when the distance is to short.

Caryl
Logged

Less is more!

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

Yes.

Why don't you try some examples and see if it'll do waht you want?
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.

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

Quote
But is it possible to add 1 to the totalcount when the distance is to short.
Of course. The question is whether you want to increment the counter repeatedly if the distance goes below some value, or only once each time the distance goes below some value?

If this is for a elementary school, you can be sure that someone will just play games until the count goes high enough.
Logged

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

Quote
But is it possible to add 1 to the totalcount when the distance is to short.
Of course. The question is whether you want to increment the counter repeatedly if the distance goes below some value, or only once each time the distance goes below some value?

If this is for a elementary school, you can be sure that someone will just play games until the count goes high enough.
When a clot goes along the Ping))), the ping))) wil activate a scanner and a light but this is impossible, we thought we better just count clots of they pass the ping)))

Btw its for a dutch school and I'm 12 years old.
Logged

Less is more!

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

Quote
When a clot goes along the Ping))), the ping))) wil activate a scanner and a light but this is impossible, we thought we better just count clots of they pass the ping)))
It's not impossible. But, you need to understand that the ping sensor is an analog sensor (something is x distance away), not a digital sensor (something is close).

So, your sensor is going to return values like 200, 200, 198, 190, 170, 150, 140, 130, 120, 100, 90, 80, 70, 60, 50, 40, 30, 20, 15, 15, 15, 15, 15, 18, 20, 30, 40, 50, 60...

If you decide that any value less than 50 means that something is being thrown away, then 40, 30, 20, 15, 15, 15, 15, 15, 18, 20, 30,  and 40 will all mean that something is being thrown away.

If you increment the counter each time you get a reading less than 50, then you would increment the counter 12 times with the sample data I showed.

If you compare the current reading (40, for instance) with the previous reading (50), and increment the counter only when the current reading is less when 50 and the previous reading is not, then with the sample data I showed, the counter would only be incremented once.

If you can increment a counter, then you can do any other action, too, such as starting the scanner and light.

Perhaps now that you see how your sensor works, you can see when you could turn the scanner and light off, too. (The current reading is above the threshold and the previous reading is not.

I'm very happy to see you learning about computer programming at such an early age, if you really are only 12. Computers are not going away, and computer programmers will always be needed.

Look around on the playground, and find code to read your sensor. Start with doing nothing but printing the distance to the serial port. When you get that working, we can work on adding the additional code to increment the counter, if you need help with that. Or, perhaps I've given you enough clues that you can figure something out. If not, don't feel bad. We'll help.
Logged

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

Dear PaulS,

Thank you. I have read about a code: if (........==.......). Can i use this code?

CekstuffertZ
Logged

Less is more!

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

Quote
Thank you. I have read about a code: if (........==.......). Can i use this code?
You can, but >= or <= are probably better choices. Expecting an exact value from an analog sensor is not a good idea.
Logged

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

So: if(AnalogRead<40) activate led.
« Last Edit: January 27, 2013, 06:09:13 pm by cekstuffertz » Logged

Less is more!

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

Quote
So: if(..........<40) activate led.
Yes, if ..... is the value read from the ping sensor (and 40 is reasonable).
Logged

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

Ohh its that easy!

thank you very much and i have now the right code to use!.
Logged

Less is more!

Pages: 1 [2]   Go Up
Jump to: