NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import RPi.GPIO as GPIO #Import GPIO library
import time #Import time library
GPIO.setmode(GPIO.BCM)
def ultrasonic():
#GPIO.setmode(GPIO.BCM) #Set GPIO pin numbering

TRIG1 = 06 #Associate pin 23 to TRIG
ECHO1 = 19 #Associate pin 24 to ECHO
TRIG2 = 13 #Associate pin 23 to TRIG
ECHO2 = 26 #Associate pin 24 to ECHO

print "Distance measurement in progress"

GPIO.setup(TRIG1,GPIO.OUT) #Set pin as GPIO out
GPIO.setup(ECHO1,GPIO.IN) #Set pin as GPIO in
GPIO.setup(TRIG2,GPIO.OUT) #Set pin as GPIO out
GPIO.setup(ECHO2,GPIO.IN) #Set pin as GPIO in

#while True:
GPIO.output(TRIG1, False) #Set TRIG as LOW
GPIO.output(TRIG2, False) #Set TRIG as LOW
print "Waitng For Sensor To Settle"
time.sleep(1) #Delay of 2 seconds

GPIO.output(TRIG1, True) #Set TRIG as HIGH
GPIO.output(TRIG2, True) #Set TRIG as HIGH
time.sleep(0.00001) #Delay of 0.00001 seconds
GPIO.output(TRIG1, False) #Set TRIG as LOW
GPIO.output(TRIG2, False) #Set TRIG as LOW
start1 = time.time()
start2 = time.time()
while GPIO.input(ECHO1)==0: #Check whether the ECHO is LOW
start1 = time.time() #Saves the last known time of LOW pulse

while GPIO.input(ECHO2)==0: #Check whether the ECHO is HIGH
start2 = time.time() #Saves the last known time of HIGH pul$

while GPIO.input(ECHO1)==1 or GPIO.input(ECHO2)==1:
if GPIO.input(ECHO1)==1:
end1 = time.time() #Saves the last known time of LOW pulse
if GPIO.input(ECHO2)==1:
end2 = time.time()
# while GPIO.input(ECHO2)==1: #Check whether the ECHO is HIGH
#end2 = time.time() #Saves the last known time of HIGH puls$

duration1 = end1 - start1 #Get pulse duration to a variable
duration2 = end2 - start2 #Get pulse duration to a variable

distance1 = duration1 * 17150 #Multiply pulse duration by 17150 to get $
distance1 = round(distance1, 2) #Round to two decimal points
distance2 = duration2 * 17150 #Multiply pulse duration by 17150 to get $
distance2 = round(distance2, 2) #Round to two decimal points

if distance1 > 2 and distance1 < 400: #Check whether the distance is with$
print "Distance1:",distance1 - 0.5,"cm" #Print distance with 0.5 cm calib$
else:
print "Out Of Range" #display out of range

if distance2 > 2 and distance2 < 400: #Check whether the distance is with$
print "Distance2:",distance2 - 0.5-8,"cm" #Print distance with 0.5 cm cal$
else:
print "Out Of Range" #display out of range
value=distance1-distance2
return value

def piezometer():
PiPin = 05
print "starting Piezometer"
GPIO.setup(PiPin, GPIO.OUT)
GPIO.output(PiPin, GPIO.LOW)
time.sleep(0.1)
value=0
i=0
GPIO.setup(PiPin, GPIO.IN)
while True:
if (GPIO.input(PiPin)==GPIO.HIGH):
value=1
i=i+1
if i==100000:

return value

def main():
value1=ultrasonic()
print "Difference in distance", value1
value2=piezometer()
print "Pressure Sensor", value2
if (value1>40 and value2 == 0)


while True:
main()

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.