Alternative button programming

Post Reply
Tinkerpete
Posts: 44
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go
Has thanked: 0
Been thanked: 0
Contact:

Alternative button programming

Unread post by Tinkerpete » Tue Oct 15, 2019 4:43 pm

Hello Everybody,

i try to call the buttons with an external library (https://github.com/LennartHennigs/Button2). I have tried the pin numbers 32, 8, 31 and 19 for A, and 33, 9, 30 and 18 for B, but it did not work.

With an an other ESP32 i get the library to run, but not with the Odroid-Go. Can anybody help me?

Thomas

Code: Select all

#include <Button2.h>

#define BUTTON_1 19 // BTN-A   IO32  8   31  IO19  uSD/EXT-Pin #7 (VSPI-MISO)
#define BUTTON_2 18 // BTN-B   IO33  9   30  IO18  LCD/uSD/EXT-Pin #2 (VSPI-SCK) 

Button2 btn1(BUTTON_1);
Button2 btn2(BUTTON_2);

void setup(void) {
  Serial.begin(115200);
  buttonInit();
}

void loop() {
  Serial.println ("Test");
  delay (1000);
}

void buttonInit() {
  Serial.println ("Button 1 init");
  btn1.setPressedHandler([](Button2 & b) {
    Serial.println ("Button 1 press");
  });

  Serial.println ("Button 2 init");
  btn2.setPressedHandler([](Button2 & b) {
    Serial.println ("Button 2 press");
  });
}

Paspartout
Posts: 36
Joined: Fri Dec 28, 2018 2:13 am
languages_spoken: english, german
ODROIDs: Odroid go
Has thanked: 3 times
Been thanked: 8 times
Contact:

Re: Alternative button programming

Unread post by Paspartout » Tue Oct 15, 2019 6:02 pm

Hello,

I think you just go your defines wrong. Button A pin should be 32 and Button B 33(see these defines for reference).

Tinkerpete
Posts: 44
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go
Has thanked: 0
Been thanked: 0
Contact:

Re: Alternative button programming

Unread post by Tinkerpete » Tue Oct 15, 2019 6:28 pm

HI Paspartout, thank you for your help! But, like i wrote, 32 and 33 did also not work!

Paspartout
Posts: 36
Joined: Fri Dec 28, 2018 2:13 am
languages_spoken: english, german
ODROIDs: Odroid go
Has thanked: 3 times
Been thanked: 8 times
Contact:

Re: Alternative button programming

Unread post by Paspartout » Tue Oct 15, 2019 7:07 pm

Ah sorry didn't get that.
Another thing that I noticed is that btn1.loop() and btn2.loop() is missing in the loop function.
Also the delay(1000) will probably interfere with these functions.

Tinkerpete
Posts: 44
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go
Has thanked: 0
Been thanked: 0
Contact:

Re: Alternative button programming

Unread post by Tinkerpete » Tue Oct 15, 2019 8:57 pm

Hi Paspartout! Many thanks for this! It works now!

Post Reply

Return to “Arduino Coding Camp”

Who is online

Users browsing this forum: No registered users and 4 guests