CNAP

Pushbutton 6mm Reference

Compact 6mm tactile pushbutton (SPST-NO), same pin layout and behaviour as the standard Pushbutton, in a smaller footprint.

Pin names

The button has four pins arranged in two pairs. Pins on the same side (1.l/2.l or 1.r/2.r) are always connected to each other internally. Pressing the button bridges the left pair to the right pair.

Pin IDLabelDescription
1.l1 LeftTerminal 1 — left side
2.l2 LeftTerminal 2 — left side (internally connected to 1.l)
1.r1 RightTerminal 1 — right side
2.r2 RightTerminal 2 — right side (internally connected to 1.r)

For most circuits you only need one pin from each side — use 1.l and 2.l (as in all CNAP templates), or 1.r and 2.r.

Attributes

NameDescriptionDefault
colorButton cap colour: "green", "red", "blue", "yellow", "white", "black""green"

Usage

Connect one pin to a GPIO, the other to GND. Enable INPUT_PULLUP in setup() — the pin reads HIGH when released, LOW when pressed. No external resistor needed.

const int BTN = 2;

void setup() {
  pinMode(BTN, INPUT_PULLUP);
  Serial.begin(9600);
  Serial.println("Press the button!");
}

void loop() {
  if (digitalRead(BTN) == LOW) {
    Serial.println("Button pressed!");
    delay(200);  // simple debounce
  }
}

Examples

DescriptionAttrs
Default green cap{}
Red cap{ "color": "red" }
Blue cap{ "color": "blue" }

See also

  • Pushbutton — larger footprint, same pin layout and logic
  • Slide Switch — maintained on/off position instead of momentary press