Single Switch Multiple Functions


In this project, I am going to teach you how to give multiple functions in a single push switch. Below is the list of different ways of using the switches for different functions,

  • Single Tap
  • Double Tap
  • Triple Tap
  • Four Tap
  • Hold
  • Tap and hold

“there can be more if you can be creative” 

Single Switch Multiple Functions - Arduino


Things Required

  • Arduino or any other compatible board
  • Micro push button
  • RGB LED, for testing the switch functions.


  • First, we calculate the time gap between each button press and the number of times the button is pressed 
  • Then according to the no. of times, the button is pressed we are calling different functions
  • like the same way if the time gap is more than the preset value then we consider it as a “hold” and we call the functions which we associate to it

watch the full video for detailed programming instructions.

Hardware Required

ComponentsDIY UsthaddiyusthadAmazon.comamazonBanggoodbanggoodAliExpressali expressUtsource
Arduino Nanocart iconcart iconcart iconcart iconcart icon
Push Buttoncart iconcart iconcart iconcart iconcart icon


Single Switch Multiple Functions - Arduino circuit
  • Connect one leg of the push button to any digital pin.
  • connect the other leg to the ground of Arduino.

Full Video

Part 1

Part 2


To buy electronic components order from UTSOURCE

3 thoughts on “Single Switch Multiple Functions”

  1. i get stock cause i wanna use the super nice snippet code. You code and tutorial is awesome. I wanna execute all void function but in if and if else statement. I have a button but 2 toggle switch too. Depending of state of the 2 toggle switch, button act different function.

    Example :
    void singleTap() {
    if (toggleA == true) {
    digitalWrite(red, LOW);
    if (toggleA == false){
    digitalWrite (green, LOW);
    if (toggleB == false){
    digitalWrite(blue, LOW);

    //‐———-same patteern for doubleTap, tripple 4th and the 2 hold and tap hold.

    thanks if you can help me to bonify your idea with toggle switch true or false that helpme a lot if you have a clue how implemented i tryhard with you original code with switch case too but no succes. something block in the code when if statement is added as toggle. iam novice but try my best thanks to help and again nice code and tutorial iam very close of the goal.

    1. Hi François Eric King, I am afraid I didn’t understand your question properly. Please share your complete code and tell me exactly what output you need. Ill try my level best to solve it for you.

Leave a Comment

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