Go Down

Topic: --- (Read 2500 times) previous topic - next topic

lostearstudio

Mar 07, 2011, 12:41 am Last Edit: Feb 06, 2015, 03:39 pm by lostearstudio Reason: erasing my account
---

liudr

Depending on how bright you want the LEDs, you can go anywhere between like 100 and 1,000 Ohms. If you have not made the actual circuit yet, get a kit of lots of resistance values and try them out. Although you need some calculation to find out the suggested value of resistance, you can also play by ear and start with a large value like 1K, then step down the resistance. Make sure you know how to use an ammeter to make sure the current doesn't exceed either 20mA for arduino pins or LED's suggested current value.

liudr

I suggest you do one sensor with one if, then find out if your scenario works or not. I am a bit concerned if there's no object in front of the sensor, you may get zero depending on what code you cut and paste. So get one sensor to work first would be best.

For learning the language, you can start with arduino programming notebook. Just google it. Then find some basic c programming book. A good master of coding is essential in moving forward.

liudr

Sure you can use all three. I was just suggesting the path of least resistance to get to a partial goal. You're a good planner (diagram is pretty good) so maybe your first stop is your final goal!

So get the sensors, play with them a bit. Type up some code and post back here for critique!

The parallax ping is a very popular sensor. It is not like a potentiometer. You need to talk to it to start the measurement, then listen on the same pin you talked to it for a pulse. The width of the pulse tells you distance (round trip).

Here, take a look at my codes for this car reverse obstacle sensor project:
http://liudr.wordpress.com/2011/02/12/arduino-parking-sensor/

It's got an intro to the sensor.

When you download my code, do the nutshell first. It's easy to read through and understand what I do. The full version has interactive features you don't need for your project (at least at this stage).

Let me know if you have questions!

liudr

You can't have 3 LEDs in series. The matrix should have rows and columns and turns on one LED at a time. You will take 33% time to turn on each one of the 3 LEDs if you want to have 3 LEDs on together. If you do it fast enough, you will think several LEDs are turned on simultaneously.

AWOL

Do you see how this:
Code: [Select]
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);

pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);

cm = microsecondsToCentimeters(duration);


looks a lot like this:
Code: [Select]
pinMode(pingPin1, OUTPUT);
digitalWrite(pingPin1, LOW);
delayMicroseconds(2);
digitalWrite(pingPin1, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin1, LOW);

pinMode(pingPin1, INPUT);
duration1 = pulseIn(pingPin1, HIGH);
?

We programmers are a lazy bunch, and hate typing more than we absolutely need to (have you ever read an APL program?), so we factor up code like that into functions, then we have only one lot of typing to do, and the bugs have fewer dusty corners to hide in.

The Arduino IDE also has a handy auto-format tool - use Ctrl-T to transform the legibility of your code.
"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.

AWOL

Quote
so that was the only way I could quickly ensure that none of the variable would interferes with each other

That is precisely the reason you should be using functions.
"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.

WillR


i see what you mean but I'm still not quite that familiar with the language and programming in general so that was the only way I could quickly ensure that none of the variable would interferes with each other. I had serious struggles with the three sensors interfering with each other and this was the only way I could get it to work together.


I put a simple Application Framework in this particular area just so that people starting out could see how simple it is to organize a program with functions and "areas of responsibility". Have a look and see if it makes things more clear. it is not very sophisticated -- it should be very easy to understand -- and for just this reason.
Just another Hacker

Go Up