dimanche 29 janvier 2017

Raspberry Pi Python - Water Level Indicator

I have a Raspberry Pi that is connected to the breadboard. I'm using a BC548 NPN transistor. I want to know what will I code if the wire(color green) touches the water and the LED will turn on. Below also is my sample code and the comment explains all.

Circuit click here

I'm using flask to have a web server. This is my code:

import RPi.GPIO as GIO
from flast import Flask

GPIO.setmode(GPIO.BOARD)
GPIO.setup(12,GPIO.OUT)
GPIO.output(12,GPOO.LOW)     //resets the led

app = Flast(__name__)
@app.route('/')
def index():
    return 'Hello'
    // i want to add code if(wire touches the water) then led will turn on and print('wire touches water')

if __name__ == '__mnain__':
    app.run(debug=True, host='0.0.0.0')

GPIO.cleanup()

I want to add something like if (wire touches water) then GPIO.output(12, 1) and print('wire touches water'). How can I do this?

Sorry I'm new to the Python language same as the Raspberry Pi. doing this for my project. My main language is Java. But I can learn the syntax of it. Thank you.




Aucun commentaire:

Enregistrer un commentaire