Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Massive LED Pushbutton Gets Stuck in Pushed State
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Massive LED Pushbutton Gets Stuck in Pushed State

by Sakuyal on Tue Feb 04, 2020 4:57 pm

Hello adafruit forums,

I recently bought one of your Massive LED Arcade Pushbuttons for a project. I've wired it correctly to my microcontroller--one switch pin to GND, another to a pin that changes from high to low when pressed--but I'm running into some strange behavior.

When I have the board connected and running off of my computer's USB power, the button will get "stuck" in the low (pushed) state after I let go for a period of several seconds, sometimes never returning back to the resting high state. However, when I have the board connected to a wall outlet with a USB port, the functionality works as intended. I tested this by printing the digitalRead value of the switch pin to the serial monitor and having the button's LED light up when pressed--if it stayed lit when unpressed, I knew the input was stuck.

At first I assumed I might need a pull-up or pull-down resistor before connecting the GND pin to GND, but adding them did not help. I've tried using a different Massive LED Pushbutton as well as the USB ports on a different PC with the same results. At this point, I'm pretty stumped as to what the problem is beyond maybe my USB cable (but I can't switch cables at the moment).

Code snippet used to test below. Any ideas or guidance would be appreciated.
Code: Select all | TOGGLE FULL SIZE
const int decisionButtonGreen = 12;
//red side goes to power, black side goes to ground for LED
const int decisionButtonGreenLED = 11;
const int decisionButtonRed = 10;
const int decisionButtonRedLED = 9;

void setup() {
  Serial.begin(9600);
  pinMode(decisionButtonGreen, INPUT);
  pinMode(decisionButtonGreenLED, OUTPUT);
  pinMode(decisionButtonRed, INPUT);
  pinMode(decisionButtonRedLED, OUTPUT);
}

void loop() {
  Serial.println(digitalRead(decisionButtonGreen));
  if(digitalRead(decisionButtonGreen) == LOW){
    digitalWrite(decisionButtonGreenLED, HIGH);
  }
  else{
    digitalWrite(decisionButtonGreenLED, LOW);
  }
    Serial.println(digitalRead(decisionButtonRed));
  if(digitalRead(decisionButtonRed) == LOW){
    digitalWrite(decisionButtonRedLED, HIGH);
  }
  else{
    digitalWrite(decisionButtonRedLED, LOW);
  }
  delay(100);
}

Sakuyal
 
Posts: 9
Joined: Tue Mar 12, 2019 2:15 am

Re: Massive LED Pushbutton Gets Stuck in Pushed State

by dastels on Tue Feb 04, 2020 5:38 pm

What microcontroller board are you using?

"I assumed I might need a pull-up or pull-down resistor before connecting the GND pin to GND, but adding them did not help." What exactly did you do?

Anyway, it sounds like it might be Serial related. What do you see is you open the serial monitor?

Dave

dastels
 
Posts: 3885
Joined: Tue Oct 20, 2015 3:22 pm

Re: Massive LED Pushbutton Gets Stuck in Pushed State

by Sakuyal on Tue Feb 04, 2020 6:14 pm

dastels wrote:What microcontroller board are you using?

"I assumed I might need a pull-up or pull-down resistor before connecting the GND pin to GND, but adding them did not help." What exactly did you do?

Anyway, it sounds like it might be Serial related. What do you see is you open the serial monitor?

Dave


Hi Dave! Thanks for replying.

I'm using a Teensy 3.2. When I open the Serial monitor, I get a string of 1s--the high, aka unpushed value--and then as soon as I push the button I get a string of 0s that continues long after I let go. Sometimes it will reset itself after ~30-40 seconds, but other times I've watched it stay on the "pushed" value for over two minutes before finally shutting off.

Edit: missed the pullup/pulldown question--I added a 10k resistor first between the switch pin and the pin on the teensy showing the toggle, and then tried adding that same resistor between the ground pin and ground. Didn't change a thing--thought it might have been a power dissipation issue.

Sakuyal
 
Posts: 9
Joined: Tue Mar 12, 2019 2:15 am

Re: Massive LED Pushbutton Gets Stuck in Pushed State

by dastels on Tue Feb 04, 2020 7:15 pm

Very odd bvehavior. It may well need a pull up. The MCU has it's own pullup on inputs. Simply use INPUT_PULLUP as the pin mode. If, for some reason that won't compile, place the 10K resistor between the input pin and 3.3v.

Dave

dastels
 
Posts: 3885
Joined: Tue Oct 20, 2015 3:22 pm

Re: Massive LED Pushbutton Gets Stuck in Pushed State

by Sakuyal on Tue Feb 04, 2020 7:19 pm

dastels wrote:Very odd bvehavior. It may well need a pull up. The MCU has it's own pullup on inputs. Simply use INPUT_PULLUP as the pin mode. If, for some reason that won't compile, place the 10K resistor between the input pin and 3.3v.

Dave


INPUT_PULLUP did the trick!! Thank you so much :')

Sakuyal
 
Posts: 9
Joined: Tue Mar 12, 2019 2:15 am

Re: Massive LED Pushbutton Gets Stuck in Pushed State

by dastels on Tue Feb 04, 2020 7:36 pm

Excellent. Next you should make sure you understand why :)

Dave

dastels
 
Posts: 3885
Joined: Tue Oct 20, 2015 3:22 pm

Re: Massive LED Pushbutton Gets Stuck in Pushed State

by Sakuyal on Tue Feb 04, 2020 7:56 pm

dastels wrote:Excellent. Next you should make sure you understand why :)

Dave


It's to help power dissipation, right? Or am I missing something? If so, would appreciate it if you could point me to where I should look.

Sakuyal
 
Posts: 9
Joined: Tue Mar 12, 2019 2:15 am

Re: Massive LED Pushbutton Gets Stuck in Pushed State

by adafruit_support_carter on Tue Feb 04, 2020 8:30 pm

Give this a read and see if it helps:
https://learn.adafruit.com/circuit-play ... ing-inputs
That was my attempt to try and explain the general issue with floating inputs. Also see the follow on pages that discuss the use of pull up/down resistors.

adafruit_support_carter
 
Posts: 17323
Joined: Tue Nov 29, 2016 2:45 pm

Re: Massive LED Pushbutton Gets Stuck in Pushed State

by Sakuyal on Tue Feb 04, 2020 8:44 pm

adafruit_support_carter wrote:Give this a read and see if it helps:
https://learn.adafruit.com/circuit-play ... ing-inputs
That was my attempt to try and explain the general issue with floating inputs. Also see the follow on pages that discuss the use of pull up/down resistors.


Thanks for this! Will give it a read.

Sakuyal
 
Posts: 9
Joined: Tue Mar 12, 2019 2:15 am

Please be positive and constructive with your questions and comments.