Go Down

### Topic: --- (Read 3210 times)previous topic - next topic

---

#### liuzengqiang

#1
##### Mar 07, 2011, 01:30 am
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.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

#### liuzengqiang

#2
##### Mar 07, 2011, 01:45 am
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.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

#### liuzengqiang

#3
##### Mar 07, 2011, 06:26 pm
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!
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

#### liuzengqiang

#4
##### Mar 21, 2011, 02:40 am
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.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

#### AWOL

#5
##### Mar 27, 2011, 05:00 pmLast Edit: Mar 27, 2011, 05:03 pm by AWOL Reason: 1
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.
I speak for myself, not Arduino.

#### AWOL

#6
##### Mar 27, 2011, 05:30 pm
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.
I speak for myself, not Arduino.

#### WillR

#7
##### Mar 27, 2011, 07:27 pm

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.

Go Up