Skip to content

GPIO digital input doesn't change state as button is pressed/realised #265

Description

@zaze06

I'm trying to update data on a screen when buttons are pressed, but the buttons whont be registered as pressed according to Pi4j
button initialization:

button1 = pi4j.create(DigitalInput.newConfigBuilder(pi4j)
                .id("button")
                .name("button 1")
                .address(GPIOPin.GPIO27)
                .pull(PullResistance.PULL_DOWN)
                .debounce(3000L)
                .provider("linuxfs-digital-input")
        );

        button2 = pi4j.create(DigitalInput.newConfigBuilder(pi4j)
                .id("button1")
                .name("button 2")
                .address(GPIOPin.GPIO22)
                .pull(PullResistance.PULL_DOWN)
                .debounce(3000L)
                .provider("linuxfs-digital-input")
        );

        button3 = pi4j.create(DigitalInput.newConfigBuilder(pi4j)
                .id("button2")
                .name("button 3")
                .address(GPIOPin.GPIO23)
                .pull(PullResistance.PULL_DOWN)
                .debounce(3000L)
                .provider("linuxfs-digital-input")
        );

        home = pi4j.create(DigitalInput.newConfigBuilder(pi4j)
                .id("button3")
                .name("button home")
                .address(GPIOPin.GPIO17)
                .pull(PullResistance.PULL_DOWN)
                .debounce(3000L)
                .provider("linuxfs-digital-input")
        );

I read the state of the buttons using the DigitalInput#isHigh() and DigitalInput#isLow() methods in a javax.swing.Timer

The timer is defined as a field and the java.awt.event.ActionListener is provided on the definition of the Timer.
The timer is started after the buttons have ben defined.

Build.gradle dependencies include com.pi4j:pi4j-plugin-linuxfs:2.3.0

Physical setup:
image

links to the code parts:
button setup
Timer forn the button reads
Build.gradle dependencies

If more information is needed I will be glad to try to provide it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions