[itsyBitsy nrf52840] Unexpected Delay

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Nlight
 
Posts: 6
Joined: Sun Aug 02, 2020 3:34 pm

[itsyBitsy nrf52840] Unexpected Delay

Post by Nlight »

I tested a simple script that simulate a switch, which sets :
  • A4 as an output set to False
  • D9 as an input
Then the main loop consists of tracking the state change of D9.
While contacting A4 and D9 is detected right away, when I break the contact, there is 2 sec delay before the input reads True again...

Why is that ?

here is the code used :

Code: Select all

import board
import digitalio
import time

def set_pin(var_name, pin_name, out=True):
    globals()[var_name] = pin = digitalio.DigitalInOut(getattr(board, pin_name))
    pin.direction = getattr(digitalio.Direction, "OUTPUT" if out else "INPUT")

set_pin("key_out", "A4")
set_pin("key_in", "D9", out=False)
set_pin("led", "BLUE_LED")
key_out.value = False #self-note :: PullUp logic : offer ground to input

#signal the code is executed
for x in range(2):
        led.value = True
        time.sleep(1)
        led.value = False
        time.sleep(1)

# visually confirm key_in.value is True
for x in range(2 if key_in.value else 10):
    led.value = True
    time.sleep(0.1)
    led.value = False
    time.sleep(0.1)

time.sleep(3)

def test():
    old_input = key_in.value
    while True :
        input = key_in.value
        if input != old_input :
            if not old_input :
                print("key Depressed")
                led.value = False
            else :
                print("key pressed")
                led.value = True
            old_input = input

test()

User avatar
Nlight
 
Posts: 6
Joined: Sun Aug 02, 2020 3:34 pm

Re: [itsyBitsy nrf52840] Unexpected Delay

Post by Nlight »

Ok, forget it, I assumed the pins was set in pullup logic by default... Nope, gotta set it manually. Ok

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”