Knop of button. Kan gebruikt worden voor puls, maar ook voor zelfvergrendeling.
| Pin | Signaal | Beschrijving |
|---|---|---|
COM |
COM | |
NO |
Normally Open |
| Van | Naar | Draad |
|---|---|---|
board:D2 |
x1:COM |
green |
board:GND |
x1:NO |
black |
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);
}
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