I've found a circuit board that has a couple of circuits (buttons, IR Receiver, LED, USB). The thing is that following the line for interfacing the buttons I came across what seems to be like buttons that are connected only to the ground line of the PCB while the other end is a free pin cable.

Is there a way for the arduino to detect the ground when the button is pressed or a way to detect a short of some kind? There is a smd and a resistor on both buttons.


Main Ground-----Button-----SMD Capacitor-----Resistor(101)-----Free Pin

Thanks in advance!

Edit: Circuit Board

Circuit Description

3 Answers 3


Just connect the ground to the ground on the arduino, and the free pin to a IO pin. Enable the pull-up resistor on that pin using pinMode(<nr>, INPUT_PULLUP);. If the button is not pressed, you will read a HIGH. If the button is pressed you will read a LOW.

  • Exactly what I wanted. Simple explanation! The internal_pullup thing was the thing that bothered me the most but it's all explained now. So thanks! Until I can confirm this I will refrain from accepting this answer :)
    – DarkXDroid
    Commented Aug 2, 2015 at 1:49
  • 1
    That's fine. Good luck on your project.
    – Gerben
    Commented Aug 2, 2015 at 8:27

It sounds like you might have a PCB with debounced switches on them. One such circuit for debouncing switches looks like this:

enter image description here

That circuit and more about switch debouncing can be found here.

A debouncer basically masks the problem of switch "bounce" which is what happens when the contacts get close and the circuit is quickly closed and opened in rapid succession until a firm connection is obtained. Its a natural problem mechanical switches.

If that's not quite right, maybe you could help us help you better by posting a photo of the board in question.

  • Well I'll do some research on debouncing... You can see my edit for further analysis on the circuit! Thanks for your concern!
    – DarkXDroid
    Commented Aug 1, 2015 at 7:34

I did some research on the subjects and I came with a solution: I borrowed the code from here and made some modifications to fit my needs.

const int buttonPin = 6;
const int buttonPin1 = 7;

int previousReading = HIGH;
int previousReading1 = HIGH; 

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(buttonPin1, INPUT_PULLUP);

void loop() {
  int reading = digitalRead(buttonPin);
  int reading1 = digitalRead(buttonPin1);

  if (previousReading == HIGH && reading == LOW) {

  if (previousReading1 == HIGH && reading1 == LOW) {

  previousReading = reading;
  previousReading1 = reading1;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.