import RPi.GPIO as gpio import time from MyMax7219 import MyMatrix from random import randint gpio.setmode(gpio.BCM) taster = [14,15,18,23] matrixe = 2 matrix = MyMatrix(cascaded=matrixe) height = 7 width = (8*matrixe)-1 def steuerung(gpio): print('steuerung') print(gpio) global richtung if(gpio == 14): #rechts richtung = [1,0] elif(gpio == 15): #oben richtung = [0,-1] elif(gpio == 18): #unten richtung = [0,1] elif(gpio == 23): #links richtung = [-1,0] for i in taster: gpio.setup(i,gpio.IN,pull_up_down=gpio.PUD_UP) gpio.add_event_detect(i, gpio.FALLING, callback=steuerung) def startSpiel(): global snake, richtung, apfel
from MyMax7219 import MyMatrix import time matrix = MyMatrix() krake = [[2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [3, 2], [4, 2], [6, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [1, 4], [3, 4], [4, 4], [5, 4], [6, 4], [1, 5], [6, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [0, 7], [1, 7], [3, 7], [4, 7], [6, 7], [7, 7]] for i in krake: matrix.pixel(i[0], i[1], 1) time.sleep(5)
from MyMax7219 import MyMatrix from random import randint import time matrix = MyMatrix() matrix.showMessage('MOIN') for i in range(9): matrix.letter(str(9 - i)) time.sleep(0.2) matrix.clear() time.sleep(0.2) for i in range(8): for j in range(8): matrix.pixel(j, i, 1) time.sleep(0.02) time.sleep(0.1) for i in range(0, 250, 20): matrix.brightness(i) time.sleep(0.2) matrix.clear() time.sleep(0.2) abc = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
import RPi.GPIO as gpio from MyMax7219 import MyMatrix from random import randint import time gpio.setmode(gpio.BCM) taster = 23 gpio.setup(taster,gpio.IN,pull_up_down=gpio.PUD_UP) matrix = MyMatrix() def neue_zahl(channel): matrix.letter(str(randint(1,6))) gpio.add_event_detect(taster, gpio.RISING, callback=neue_zahl) matrix.letter("?") while True: time.sleep(0.01)
import RPi.GPIO as gpio from MyMax7219 import MyMatrix from random import randint import time matrix = MyMatrix() while True: for i in range(8): for j in range(8): matrix.pixel(i, j, randint(0, 1)) time.sleep(0.0002)