sampler.py 422 Bytes
Newer Older
Nicholas Gar Hei Chan's avatar
Nicholas Gar Hei Chan committed
1
2
3
4
5
6
7
8
9
10
11
12
13
import os
import subprocess
import time

def sample_probe(solenoid_pin, sense_pin, delay_time):
	os.system("gpio mode {} in".format(sense_pin))
	os.system("gpio mode {} out".format(solenoid_pin))

	os.system("gpio write {} 1".format(solenoid_pin))
	time.sleep(delay_time)
	res = subprocess.check_output("gpio read {}".format(sense_pin), shell=True)
	os.system("gpio write {} 0".format(solenoid_pin))
	return int(res) == 0