from machine import Pin, I2C, Timer
import ssd1306
# ESP32 Pin assignment
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
def timer1_tick(_):
global CountA
oled.fill(0)
oled.text(str('A takes {} match'.format(CountA,)), 0, 0, 1)
oled.show()
def attachInterrupt_func(x):
global CountA
CountA = CountA + 1
tim1.deinit()
tim1.init(period=2000, mode=Timer.ONE_SHOT, callback=timer1_tick)
tim1 = Timer(1)
CountA = 0
pin25 = Pin(25, Pin.IN)
Pin(25).irq(handler = attachInterrupt_func, trigger = Pin.IRQ_RISING)