Knop of button. Kan gebruikt worden voor pulse maar ook voor self-lock.
| Pin | Signal | Description |
|---|---|---|
COM |
COM | |
NO |
Normally Open |
| From | To | Wire |
|---|---|---|
board:D2 |
x1:COM |
green |
board:GND |
x1:NO |
black |
This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.
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);
}
Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.
Start for free