Cmcdaid wrote:I think there is enough pins to directly attach the another ultrasonic module to the GPIO (same setup just other half of the breadboard?) but how can I learn or what will I need to do to the code so that it takes the two measurements and multiples them to show the area? Do I need to phone my computer science pal or is it relatively simple lol?
This is a final year (undergraduate) project? I think evidence of a bit of thinking and research might earn you marks! Or maybe you have chosen the wrong project because it is getting a bit late to learn a programming language...
Look at what you have already got.
Code: Select all
# Define GPIO to use on Pi
GPIO_TRIGGER = 23
GPIO_ECHO = 24
So it takes 2 pins to connect your module. The RPi has 17 gpio pins - see
http://elinux.org/RPi_Low-level_periphe ... ion_header - so there are plenty of pins spare to connect another module.
You already have code from Matt Hawkins that shows you how to process the input from the module to get the corresponding distance.
Code: Select all
# Send 10us pulse to trigger
GPIO.output(GPIO_TRIGGER, True)
time.sleep(0.00001)
GPIO.output(GPIO_TRIGGER, False)
start = time.time()
while GPIO.input(GPIO_ECHO)==0:
start = time.time()
while GPIO.input(GPIO_ECHO)==1:
stop = time.time()
# Calculate pulse length
elapsed = stop-start
# Distance pulse travelled in that time is time
# multiplied by the speed of sound (cm/s)
distance = elapsed * 34000
# That was the distance there and back so halve the value
distance = distance / 2
print "Distance : %.1f" % distance
You simply need to replicate that with your newly chosen Trigger and Echo pins, then 'multiple' the two results.
If you don't know enough Python to be able to make that simple change you will need to call on help from your 'computer science pal.' Whether or not you need her help, I hope your project will acknowledge that the code you have submitted is not your own work.
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html