0

I'm writing a Python script for a piezo buzzer connected to a Raspberry Pi GPIO. Hears what iv'e got so far.

import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.OUT)

time = 0.001

try:
        while True:
            GPIO.output(24, 1)
            sleep(time)
            GPIO.output(24, 0)
            sleep(time)

except:
    GPIO.cleanup()
    print "GPIO Cleaned Up!"

I want to be able to change the time variable by pressing the up and down arrows on my keyboard when the 'While True' loop is running. Any help would be appreciated!

EDIT: It would be nice if it could work through ssh.

1 Answers1

2

Please see this link it explains how to read keystrokes in Python.

Community
  • 1
  • 1
chevydog
  • 123
  • 7