MCPcopy Create free account
hub / github.com/SiddhantSilwal/RaspberryPi-GPIO-Web-Controller / read_pin_value

Function read_pin_value

AppData/app.py:154–164  ·  view source on GitHub ↗

Read current value from a pin

(pin)

Source from the content-addressed store, hash-verified

152 time.sleep(1)
153
154def read_pin_value(pin):
155 """Read current value from a pin"""
156 if GPIO_BACKEND == 'gpiozero':
157 device = pin_states.get(pin, {}).get('device')
158 if device:
159 return 1 if device.value else 0
160 return 0
161 elif GPIO_BACKEND == 'RPi.GPIO':
162 return GPIO.input(pin)
163 else: # mock
164 return GPIO.input(pin)
165
166@app.route('/')
167def index():

Callers 2

input_monitor_workerFunction · 0.85
get_pinsFunction · 0.85

Calls 1

inputMethod · 0.80

Tested by

no test coverage detected