EveryCircuit
Contact
Reviews
Home
nforystek
modified 3 months ago

Seven Buttons with Three Logics

2
0
143
01:06:13
I use this method with an Arduino when I only have so many digital pins (three) and want more buttons (seven in this case). Where as the LED's represent the logic inputs to the Arduino, Inside the software source you would preform checks for multiple logic patterns of simultaneous inputs at a single instant and know the corresponding button. Here is a wokwi version: https://wokwi.com/projects/454438811343692801 Code: /* seven buttons with three pins circuit at https://everycircuit.com/circuit/6148761842352128 connect the positive of the LED's in the circuit to these pins below and the negative to ground, also the 5v substituted to the Arduino 5v and GND */ #define pin1 2 #define pin2 3 #define pin3 4 void setup() { pinMode(pin1, INPUT); pinMode(pin2, INPUT); pinMode(pin3, INPUT); Serial.begin(115200); } void loop() { byte btnBits=digitalRead(pin1)?1:0; btnBits+=digitalRead(pin2)?2:0; btnBits+=digitalRead(pin1)?4:0; static bool toggle=false; if ((btnBits!=0)&&(!toggle)) { toggle=true; Serial.print("Button "); Serial.print(btnBits); Serial.println(" Pressed"); } else toggle=false; } // - nforystek
published 5 years ago

EveryCircuit is an easy to use, highly interactive circuit simulator and schematic capture tool. Real-time circuit simulation, interactivity, and dynamic visualization make it a must have application for professionals and academia. EveryCircuit user community has collaboratively created the largest searchable library of circuit designs. EveryCircuit app runs online in popular browsers and on mobile phones and tablets, enabling you to capture design ideas and learn electronics on the go.

Copyright © 2026 by MuseMaze, Inc.     Terms of use     Privacy policy