cat display fertig.
This commit is contained in:
24
local_code/app.py
Normal file
24
local_code/app.py
Normal file
@ -0,0 +1,24 @@
|
||||
from RPi import GPIO
|
||||
import time
|
||||
|
||||
# Set up GPIO pin (example using BCM pin 14)
|
||||
GPIO_PIN = 26
|
||||
|
||||
def setup():
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(GPIO_PIN, GPIO.IN)
|
||||
|
||||
def loop():
|
||||
Messwert = GPIO.input(GPIO_PIN) # Read analog value from the pin
|
||||
Spannung = ((Messwert * 250) / 1023) / 10 # Map and scale to desired range (0-2.5V)
|
||||
print(f"Spannung: {Spannung:.2f} V") # Print with two decimal places
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup()
|
||||
try:
|
||||
while True:
|
||||
loop()
|
||||
except KeyboardInterrupt:
|
||||
GPIO.cleanup() # Clean up when Ctrl+C is pressed
|
Reference in New Issue
Block a user