Hi,
I purchased a 4 x 4 keyboard like in the picture. I want to use it in a codesys project. I'm using this cheat:
import RPi.GPIO as GPIO
import time
L1 = 16
L2 = 20
L3 = 21
L4 = 26
C1 = 5
C2 = 6
C3 = 13
C4 = 19
GPIO.setwarnings (False) GPIO.setmode (GPIO.BCM) GPIO.setup (L1, GPIO.OUT) GPIO.setup (L2, GPIO.OUT) GPIO.setup (L3, GPIO.OUT) GPIO.setup (L4, GPIO.OUT) GPIO.setup (C1, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) GPIO.setup (C2, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) GPIO.setup (C3, GPIO.IN, pull_up_down = GPIO. PUD_DOWN) GPIO.setup (C4, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) def readLine (line, characters): GPIO.output (line, GPIO.HIGH) if (GPIO.input (C1) == 1): print (characters [0]) if (GPIO.input (C2) == 1): print (characters [1]) if (GPIO.input (C3) == 1): print (characters [2]) if (GPIO. input (C4) == 1): print (characters [3]) GPIO.output (line, GPIO.LOW) try: while True: readLine (L1, ["1", "2", "3", "A "]) readLine (L2, [" 4 "," 5 "," 6 "," B "]) readLine (L3, [" 7 "," 8 "," 9 "," C "]) readLine (L4 , ["*", "0", "#", "D"]) time.sleep (0.1) except KeyboardInterrupt: print ("\ nApplication stopped!")
Codesys only reads buttons from rows (reads signal for 4 buttons). Does not read the signal from the columns. The keyboard is connected to gpio 5,6,13,19,16,20,21,26. The code written in python makes it possible to read each button. What can I do with it to make codesys read every button?
Hi,
I purchased a 4 x 4 keyboard like in the picture. I want to use it in a codesys project. I'm using this cheat:
import RPi.GPIO as GPIO
import time
L1 = 16
L2 = 20
L3 = 21
L4 = 26
C1 = 5
C2 = 6
C3 = 13
C4 = 19
GPIO.setwarnings (False) GPIO.setmode (GPIO.BCM) GPIO.setup (L1, GPIO.OUT) GPIO.setup (L2, GPIO.OUT) GPIO.setup (L3, GPIO.OUT) GPIO.setup (L4, GPIO.OUT) GPIO.setup (C1, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) GPIO.setup (C2, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) GPIO.setup (C3, GPIO.IN, pull_up_down = GPIO. PUD_DOWN) GPIO.setup (C4, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) def readLine (line, characters): GPIO.output (line, GPIO.HIGH) if (GPIO.input (C1) == 1): print (characters [0]) if (GPIO.input (C2) == 1): print (characters [1]) if (GPIO.input (C3) == 1): print (characters [2]) if (GPIO. input (C4) == 1): print (characters [3]) GPIO.output (line, GPIO.LOW) try: while True: readLine (L1, ["1", "2", "3", "A "]) readLine (L2, [" 4 "," 5 "," 6 "," B "]) readLine (L3, [" 7 "," 8 "," 9 "," C "]) readLine (L4 , ["*", "0", "#", "D"]) time.sleep (0.1) except KeyboardInterrupt: print ("\ nApplication stopped!")
Codesys only reads buttons from rows (reads signal for 4 buttons). Does not read the signal from the columns. The keyboard is connected to gpio 5,6,13,19,16,20,21,26. The code written in python makes it possible to read each button. What can I do with it to make codesys read every button?