Do you guys have any suggestions? I'm also sure that the code can be cleaned up some. If you want to make suggestions on that I would be interested in hearing what you have to say too. I'm still very much a beginner.
Code: Select all
import machine
import time
import tm1637
from machine import Pin
remote = machine.Pin(15, machine.Pin.IN, machine.Pin.PULL_UP)
response = machine.Pin(13, machine.Pin.IN, machine.Pin.PULL_UP)
reset = machine.Pin(14, machine.Pin.IN, machine.Pin.PULL_UP)
led = machine.Pin(2, machine.Pin.OUT)
beeper = machine.Pin(0, machine.Pin.OUT)
tm = tm1637.TM1637(clk=Pin(4), dio=Pin(5))
buttonCounter = 0
trackerCounter = 0
while True:
remotefirst = remote.value()
responsefirst = response.value()
resetfirst = reset.value()
time.sleep(0.01)
remotesecond = remote.value()
responsesecond = response.value()
resetsecond = reset.value()
if remotefirst and not remotesecond and buttonCounter != 0:
print('beeper')
beeper(1)
time.sleep(0.1)
beeper(0)
buttonCounter = buttonCounter + 1
print('buttonCounter =', buttonCounter)
trackerCounter = trackerCounter + 1
print('trackerCounter =', trackerCounter)
tm.number(trackerCounter)
if remotefirst and not remotesecond and buttonCounter == 0:
print('Remote button pressed')
led(1)
buttonCounter = buttonCounter + 1
print('buttonCounter =', buttonCounter)
trackerCounter = trackerCounter + 1
print('trackerCounter =', trackerCounter)
tm.number(trackerCounter)
if responsefirst and not responsesecond:
print('Response')
led(0)
buttonCounter = 0
print('buttonCounter =', buttonCounter)
print('trackerCounter =', trackerCounter)
tm.number(trackerCounter)
if resetfirst and not resetsecond:
print('Reset')
led(0)
buttonCounter = 0
print('buttonCounter =', buttonCounter)
trackerCounter = 0
print('trackerCounter =', trackerCounter)
tm.number(trackerCounter)