Codey OnlineArduino- & ESP32-componentenbibliotheek › Drukknop
Drukknop
Input & knoppen

Drukknop

Knop of button. Kan gebruikt worden voor puls, maar ook voor zelfvergrendeling.

Breedte: 14.7 mm

Pinout — Drukknop

Pin Signaal Beschrijving
COM COM
NO Normally Open

Voorbeeld-aansluitschema — Drukknop

Van Naar Draad
board:D2 x1:COM green
board:GND x1:NO black

Voorbeeld-Arduinocode — Drukknop

Dit voorbeeld is geschreven en compile-gecheckt voor de arduino-uno. Codey Online past het voor je aan naar elk ander ondersteund board.

const int buttonPin = 2;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  Serial.println("Drukknop example started. Press the button to connect the input to GND.");
}

void loop() {
  int buttonState = digitalRead(buttonPin);

  if (buttonState == LOW) {
    Serial.println("Button pressed");
  } else {
    Serial.println("Button released");
  }

  delay(200);
}

Vergelijkbare componenten

HX711 Load Cell Amplifier

HX711 Load Cell Amplifier

Keypad 4x3

Keypad 4x3

Tactile switch

Tactile switch

Bouw je Arduino- of ESP32-project met AI

Beschrijf wat je wilt bouwen. Codey Online schrijft de code, tekent het aansluitschema, compileert het en flasht je board rechtstreeks vanuit de browser.

Gratis starten