Code: Select all
from pyb import Pin
cletters = ['Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7', 'Y8']
rnumbers = ['X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8']
board = [[0 for j in range(8)] for i in range(8)]
rcount = 0
ccount = 0
for number in rnumbers:
Pin(number, Pin.OUT_PP)
Pin(number).high
for letter in cletters:
Pin(letter, Pin.OUT_PP)
Pin(letter).low
for row in board:
list1 = []
pnum = rnumbers[rcount]
Pin(pnum, Pin.OUT_PP)
Pin(pnum).low
ccount = 0
for e in row:
plet = cletters[ccount]
p_in = Pin(plet, Pin.IN, Pin.PULL_UP)
board[rcount][ccount] = p_in.value()
pvalue = p_in.value()
list1.append(pvalue)
ccount = ccount + 1
rcount = rcount + 1
Pin(pnum).high
print(list1)
print(board)
Code: Select all
>>>
PYB: sync filesystems
PYB: soft reboot
[0, 1, 1, 1, 1, 1, 1, 1]
[0, 1, 1, 1, 1, 1, 1, 1]
[0, 1, 1, 1, 1, 1, 1, 1]
[0, 1, 1, 1, 1, 1, 1, 1]
[0, 1, 1, 1, 1, 1, 1, 1]
[0, 1, 1, 1, 1, 1, 1, 1]
[0, 1, 1, 1, 1, 1, 1, 1]
[0, 1, 1, 1, 1, 1, 1, 1]
[[0, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1]]
MicroPython v1.5-100-g57e00ef on 2015-11-08; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>>
Thanks,
Mike