Categories
TUTORIALS

play with arcade buttons

ARCADE BUTTONS WITH LED

A button is a button, and a switch is a switch, but the translucent arcade buttons are in a class of their own. Particularly because they have LEDs built in. The arcade buttons can often be found on retro arcade game machines.

The arcade buttons have two surface mount LEDs with resistors built in, buried in the button body. There are two ground terminals on the buttons need to be wired to GND on the Arduino’s GND pins. The button control terminal and LED control terminal need to be wired to pins on the Arduino separately. The two LEDs are connected in parallel with a 200ohm resistor, so you can power the LED from 5V power source.

INTRODUCTION

The whole project aims at helping the overdose patients with first-aid kit installed on the SEPTA regional rail trains. Each train has one first-aid kit installed next to the emergency button. When a first responder inspects a person who is overdose and needs help, he can press the emergency button to contact the train operator to unlock the first-aid kit box remotely. The code of the first-aid kit is based on the number of the train where the kit is installed. So for example, if the first-aid kit needed to be open is installed in train No.1, the emergency button in train No.1 will send this signal to the operation room, the arcade button that controls the Kit No.1 will be lit on.

A part of the project is to achieve the communication between the train operator’s button for unlocking the first-aid kit and the first responder’s emergency button for sending the signal. The circuit is based on the assumption that the buttons are wired in the train.

In this tutorial, we are going to use pushbuttons, arcade buttons and Arduino. This circuit goes through the following steps: Firstly, light on the LED installed in the arcade buttons by pressing the pushbutton. Two arcade buttons are controlled respectively by two push buttons. If you push button 1, the LED in the arcade button 1 will be lit on. If you push button 2, the LED in the arcade button 2 will be lit on. The lit arcade button alerts the user to press it. If you press the lit arcade button, the LED will be turned off.

COMPONENTS

  • Two pushbuttons 
  • Two arcade buttons with LED
  • Two 330ohm resistors
  • Several wires
  • Arduino board
  • Breadboard

CIRCUIT

The picture below provides a visual reference for wiring of the components. The LEDs are embedded into the arcade buttons but for clarity, the LEDs are drawn separately from the arcade buttons. The buttons and LEDs will share a common ground.

To power this project, connect microUSB to a computer’s USB port. This doesn’t require any external power like from a battery.

  • D2, D3 from Arduino Uno to Pushbutton 1 and Pushbutton 2
  • D9, D10 from Arduino Uno to Arcadebutton LED 1 and Arcadebutton LED 2
  • D12, D13 from Arduino Uno to Arcadebutton 1 and Arcadebutton 2
  • Ground from Arduino Uno to Arcade buttons and Pushbuttons
  • 330 Ohm resistors are needed for push buttons and LEDs

CODE

Connect one side of the pushbutton to GND, and the other side to a digital pin. When you press down on the pushbutton, the pin will be connected to GND, and therefore will be read as “LOW” by the Arduino. Then connect two sides of the arcade button to GND, and the other two sides to two digital pins. One is to control the LED function in the arcade button, and the other is to control the button pressing function in the arcade button.

const int button1Pin = 2;  // pushbutton 1 pin
const int button2Pin = 3;  // pushbutton 2 pin
const int arcadebuttonled1Pin =  9; // arcadebuttonled 1 pin
const int arcadebuttonled2Pin =  10;// arcadebuttonled 2 pin
const int arcadebutton1Pin =  12;   // arcadebutton 1 pin
const int arcadebutton2Pin =  13;   // arcadebutton 2 pin

Set up the pushbuttons, arcade buttons and LEDs.

void setup() {
  // Set up the pushbutton pins to be an input:
  pinMode(button1Pin, INPUT);
  pinMode(button2Pin, INPUT);
  
  // Set up the arcadebutton pins to be an input:
  pinMode(arcadebutton1Pin, INPUT);
  pinMode(arcadebutton2Pin, INPUT);

  // Set up the arcadebuttonLED pin to be an output:
  pinMode(arcadebuttonled1Pin, OUTPUT);      
  pinMode(arcadebuttonled2Pin, OUTPUT); 
}
void loop() 
{
  int button1State, button2State;  // variables to hold the pushbutton states
  int arcadebutton1State, arcadebutton2State;  // variables to hold the arcadebutton states

  // Here we'll read the current pushbutton states into
  // two variables:
  button1State = digitalRead(button1Pin);
  button2State = digitalRead(button2Pin);

  // Here we'll read the current arcadebutton states into
  // two variables:
  arcadebutton1State = digitalRead(arcadebutton1Pin);
  arcadebutton2State = digitalRead(arcadebutton2Pin);


  // If button1 is being pressed, light up the arcadebuttonled1
  if (button1State == LOW)
    {
       digitalWrite(arcadebuttonled1Pin, HIGH); // light up the arcadebuttonled1  

       
       //  If arcadebutton1 is being pressed, turn off the arcadebuttonled1
       if (arcadebutton1State == LOW)
         {
          digitalWrite(arcadebuttonled1Pin, LOW);  // turn off the arcadebuttonled1
         }
     }
  
  // If button2 is being pressed, light up the arcadebuttonled2
  if (button2State == LOW)
    {
       digitalWrite(arcadebuttonled2Pin, HIGH);  // light up the arcadebuttonled2
       
       //  If arcadebutton2 is being pressed, turn off the arcadebuttonled2
       if (arcadebutton2State == LOW)
         {
          digitalWrite(arcadebuttonled2Pin, LOW);  // turn off the arcadebuttonled2
         }
    }
}

HOW IT WORKS

REFERENCE

Arduino Example Sketch 05 Push Buttons https://learn.adafruit.com/arcade-button-control-box/circuit-diagram https://learn.adafruit.com/arcade-button-control-box/overview https://www.adafruit.com/product/3491

Leave a Reply

Your email address will not be published. Required fields are marked *