Instructions

KY-023 Joystick Modul (XY-Achsen)
Ausgabe: 29.04.2016 Copyright by Joy-IT - Published under CC BY-NC-SA 3.0 Seite 109 von 227
# ########
# Hauptprogrammschleife
# ########
# Das Programm liest die aktuellen Werte der Eingang-Pins
# und gibt diese in der Konsole aus
try:
while True:
#Aktuelle Werte werden aufgenommen
x = adc.readADCSingleEnded(x_adc_channel, gain, sps)
y = adc.readADCSingleEnded(y_adc_channel, gain, sps)
# Ausgabe auf die Konsole
if GPIO.input(Button_PIN) == True:
print "X-Achse:", x,"mV, ","Y-Achse:", y,"mV, Button: nicht gedrückt"
else:
print "X-Achse:", x, "mV, ", "Y-Achse:", y, "mV, Button: gedrückt"
print "---------------------------------------"
# Reset + Delay
button_pressed = False
time.sleep(delayTime)
except KeyboardInterrupt:
GPIO.cleanup()
Anschlussbelegung Raspberry Pi:
Sensor KY-023
Knopf = GPIO24 [Pin 18 (RPi)]
Y-Position = Analog 1 [Pin A1 (ADS1115 - KY-053)]
X-Position = Analog 0 [Pin A0 (ADS1115 - KY-053)]
+V = 3,3V [Pin 1 (RPi)]
GND = Masse [Pin 6 (RPi)]
ADS1115 - KY-053:
VDD = 3,3V [Pin 01]
GND = Masse [Pin 09]
SCL = GPIO03 / SCL [Pin 05 (RPi)]
SDA = GPIO02 / SDA [Pin 03 (RPi)]
A0 = s.o. [Sensor: X-Position (KY-023)]
A1 = s.o. [Sensor: Y-Position (KY-023)]
Beispielprogramm Download
KY-023_RPi_JoystickModule.zip
Zu starten mit dem Befehl:
sudo python KY-023_RPi_JoystickModule.py