1×4 Keypad Pinout
Kode Program
const int buttonPin1 = 36;
const int buttonPin2 = 39;
const int buttonPin3 = 34;
const int buttonPin4 = 35;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
void setup() {
Serial.begin(9600);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
}
void loop() {
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
if (buttonState1 == LOW) {
Serial.println("Button 1 Pressed!");
}
if (buttonState2 == LOW) {
Serial.println("Button 2 Pressed!");
}
if (buttonState3 == LOW) {
Serial.println("Button 3 Pressed!");
}
if (buttonState4 == LOW) {
Serial.println("Button 4 Pressed!");
}
delay(150);
}