Am playing whole afternoon with this problem and i can not figure out what's wrong.
The funny part is that i can not print out numbers or letters, accept characters from one row and one column.
If i press 4 , output will be ( depending on button press timer ) 1,4,1,4,7,*,1,4,4,7,* etc.
If i press 5 , output will be ( depending on button press timer ) 2,2,5,8,2,0,5,8,0,5,* etc.
I have try ed different connections,checked the flat cable, wires, resistor ( on input rows ) etc. but i always get the same situation. I guess that the char print out can be controlled with sleep time, but why can i read just the ones from one column and one row ?
Code: Select all
#!/usr/bin/python import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) MATRIX = [ [1,2,3,'A'], [4,5,6,'B'], [7,8,9,'C'], ['*',0,'#','D']] ROW = [33,32,31,29] COL = [23,21,19,15] for j in range(4): GPIO.setup(COL[j], GPIO.OUT) GPIO.output(COL[j], 1) for i in range(4) : GPIO.setup(ROW[i], GPIO.IN, pull_up_down = GPIO.PUD_UP) try: while (True): # test # for j in range(4): GPIO.output(COL[j], 0) for i in range(4) : if GPIO.input (ROW) == 0: print MATRIX[i][j] while(GPIO.input(ROW[i]) == 0): pass GPIO.output(COL[j],1) #time.sleep(0.2) except KeyboardInterrupt: GPIO.cleanup()