Once adjbell and commutator go high, the normal led should stay on until the timer reaches 450 then it is supposed to go out and the led coming led goes on however, the coming led switches in while the count is still very low.
I would be grateful for any help or suggestions
Code: Select all
import time
import machine
import utime
# set up LEDs, buttons and switches
bell = machine.Pin(14, machine.Pin.IN, machine.Pin.PULL_DOWN)
adjbell = machine.Pin(22, machine.Pin.IN, machine.Pin.PULL_DOWN)
commutator = machine.Pin(15, machine.Pin.IN, machine.Pin.PULL_DOWN)
cancel = machine.Pin(9, machine.Pin.IN, machine.Pin.PULL_DOWN)
sealcancel = machine.Pin(8, machine.Pin.IN, machine.Pin.PULL_DOWN)
led_normal = machine.Pin(12, machine.Pin.OUT)
led_normal.high()
led_coming = machine.Pin(13, machine.Pin.OUT)
led_coming.low()
led_going = machine.Pin(11, machine.Pin.OUT)
led_going.low()
elapsed = 0
# end of setup section
# Normal state
while adjbell.value() == 1:
if elapsed <= 450 and adjbell.value() == 1 and commutator.value() == 1:
elapsed = (elapsed + 1)
print(elapsed)
print("ordinary bell")
print (adjbell.value(),commutator.value())
led_normal.high()
led_coming.low()
else:
if elapsed > 450 and adjbell.value() == 1 and commutator.value() == 1:
print("long bell")
led_coming.high()