0

Writing code to control the LED in an LED Arcade Button
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Writing code to control the LED in an LED Arcade Button

by kgrove on Fri Mar 05, 2021 9:58 pm

I'm pretty new to this, but I'm using CircuitPython and a Metro M0 Express. I am trying to figure out how to turn on/off the Arcade Button w/ LED https://www.adafruit.com/product/3489.

I don't know if there is something special in my code that I need to do, but so far this is the code I have for it.
Code: Select all | TOGGLE FULL SIZE
start_stop_home = DigitalInOut(board.D11)
start_stop_home.direction = Direction.INPUT
start_stop_home.pull = Pull.UP

start_stop_away = DigitalInOut(board.D12)
start_stop_away.direction = Direction.INPUT
start_stop_away.pull = Pull.UP

start_stop_away_state = False
start_stop_home_state = False


But the LED remains on even with the False state.

There is a chance I have it wired incorrectly. I have the buttons hooked up to Digital In 11 & 12. Then I have the LED's hooked up to 5V port. Both running to respected grounds. Tried looking up how some of the projects with these buttons have them set up code wise, but there isn't really much out there on how to get the LED's working responsively.

Thanks in advance

kgrove
 
Posts: 36
Joined: Wed Feb 17, 2021 4:51 pm

Re: Writing code to control the LED in an LED Arcade Button

by oliviasmithh900 on Sun Mar 07, 2021 6:42 pm

Share your circuit diagram, try using pull up resistor in hardware, I think that will resolve the issue

oliviasmithh900
 
Posts: 11
Joined: Sat Mar 06, 2021 11:07 pm

Re: Writing code to control the LED in an LED Arcade Button

by kgrove on Sun Mar 07, 2021 10:22 pm

I got it working. I finally found some code that showed me I needed to connect the led to a digital OUTPUT.

Like so:

Code: Select all | TOGGLE FULL SIZE
button_led = DigitalInOut(board.D4)
button_led.direction = Direction.OUTPUT
button_led.value = False/True

kgrove
 
Posts: 36
Joined: Wed Feb 17, 2021 4:51 pm

Re: Writing code to control the LED in an LED Arcade Button

by jwcooper on Mon Mar 08, 2021 12:22 pm

kgrove wrote:I got it working. I finally found some code that showed me I needed to connect the led to a digital OUTPUT.

Like so:

Code: Select all | TOGGLE FULL SIZE
button_led = DigitalInOut(board.D4)
button_led.direction = Direction.OUTPUT
button_led.value = False/True


Thank you for following up with your solution. Should be useful to others in the future as well.

jwcooper
 
Posts: 774
Joined: Tue May 01, 2012 9:08 pm

Please be positive and constructive with your questions and comments.