0

Button B on OLED FeatherWing and M0 Basic behaving inconsist
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Button B on OLED FeatherWing and M0 Basic behaving inconsist

by waffles317 on Sat Feb 09, 2019 6:33 pm

Hello!

I am using an Feather M0 Basic and 128x32 OLED FeatherWing stacked on top of each other. I'm having an issue with the B button on the FeatherWing, when I setup the button as INPUT_PULLUP and check for !digitalRead(BUTTON_B) I get no response. My assumption is that the button b is pulled up (described in documentation), so pressing B will bring the state to low. However, "B" does not show up when I press the button. Here is my code:

Code: Select all | TOGGLE FULL SIZE
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <CountdownLib.h>

// This pinout is specfic to the following feather boards
// ATmega328P, Atmega32u4, ATSAMD51 M4 or ATSAMD21 M0 Feather
#define BUTTON_A  9
#define BUTTON_B  6
#define BUTTON_C  5
#define OLED_RESET -1

// Initialize OLED
Adafruit_SSD1306 display(OLED_RESET);

void setup()
{
  // I2C address is 0x3C!
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

  // Button B has pullup built in.
  pinMode(BUTTON_A, INPUT_PULLUP);
  pinMode(BUTTON_B, INPUT_PULLUP);
  pinMode(BUTTON_C, INPUT_PULLUP);

  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("WORKING");
  display.display();
}

void loop()
{
  if(!digitalRead(BUTTON_A))
  {
    display.clearDisplay();
    display.setCursor(0,0);
    display.print("LUNCH\n");
    display.display();
  }

  if(!digitalRead(BUTTON_B))
  {
    display.clearDisplay();
    display.setCursor(0,0);
    display.print("B\n");
    display.display();
  }

  if(!digitalRead(BUTTON_C))
  {

    display.clearDisplay();
    display.setCursor(0,0);
    display.print("GONE \nFISHIN'");
    display.display();
  }
}


I've also tried: (1) Setting button as INPUT, check for !digitalread(), which just maked the OLED only show "B" as if the button is pressed all the time. (2) Setting button as INPUT, check for digitalread(), which just maked the OLED does not show "B" on a button push.

Thanks for the help!

waffles317
 
Posts: 1
Joined: Wed Nov 02, 2016 1:39 pm

Re: Button B on OLED FeatherWing and M0 Basic behaving incon

by adafruit_support_mike on Mon Feb 11, 2019 1:24 am

To get a baseline, try the code from the OLED FeatherWing tutorial and see if that does what it should:

https://learn.adafruit.com/adafruit-ole ... wing/usage

adafruit_support_mike
 
Posts: 57354
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.