Skip to content

Commit

Permalink
tab
Browse files Browse the repository at this point in the history
  • Loading branch information
nalbam committed Aug 27, 2019
1 parent 957eae5 commit 6d50a66
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ http.listen(port, function () {

// gpio
gpio.on('change', function (channel, value) {
console.log(`Channel ${channel} value is now ${value} - ${(Math.random() * 100000)}`);
console.log(`Channel ${channel} value is now ${value} \t- ${(Math.random() * 100000)}`);
if (channel === 7) {
io.sockets.emit('call', 'press');
} else if (channel === 37) {
Expand Down
38 changes: 38 additions & 0 deletions src/pressure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/local/bin/python

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

# define the pin that goes to the circuit
pin_to_circuit = 4


def rc_time(pin_to_circuit):
count = 0

# Output on the pin for
GPIO.setup(pin_to_circuit, GPIO.OUT)
GPIO.output(pin_to_circuit, GPIO.LOW)
time.sleep(0.1)

# Change the pin back to input
GPIO.setup(pin_to_circuit, GPIO.IN)

# Count until the pin goes high
while (GPIO.input(pin_to_circuit) == GPIO.LOW):
count += 1

return count


# Catch when script is interrupted, cleanup correctly
try:
# Main loop
while True:
print(rc_time(pin_to_circuit))
except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()

0 comments on commit 6d50a66

Please sign in to comment.