#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LedControl.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
LedControl lc=LedControl(12, 11, 10, 1); // Pin numbers for the dot matrix (data, clock, load, number of max7219 chips)
const int buzzerPin1 = 2;
const int buzzerPin2 = 3;
const int buzzerPin3 = 4;
const int buttonPin1 = 5;
const int buttonPin2 = 6;
const int buttonPin3 = 7;
const int buttonPin4 = 8;
const int buttonPin5 = 9;
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Nama: John Doe");
lcd.setCursor(0, 1);
lcd.print("NIM: 1234567890");
pinMode(buzzerPin1, OUTPUT);
pinMode(buzzerPin2, OUTPUT);
pinMode(buzzerPin3, OUTPUT);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
pinMode(buttonPin3, INPUT_PULLUP);
pinMode(buttonPin4, INPUT_PULLUP);
pinMode(buttonPin5, INPUT_PULLUP);
lc.shutdown(0, false); // Wake up the display
lc.setIntensity(0, 8); // Set the brightness (0-15)
lc.clearDisplay(0); // Clear the display
}
void loop() {
// Check for button presses and trigger actions
if (digitalRead(buttonPin1) == LOW) {
playBuzzer(buzzerPin1, 1000);
displayDotMatrix("Hello");
delay(500);
}
if (digitalRead(buttonPin2) == LOW) {
playBuzzer(buzzerPin2, 1500);
// Add more actions or functions as needed
delay(500);
}
if (digitalRead(buttonPin3) == LOW) {
playBuzzer(buzzerPin3, 2000);
// Add more actions or functions as needed
delay(500);
}
// Add more conditions for other buttons if needed
// Main program logic if needed
}
void playBuzzer(int buzzerPin, int frequency) {
tone(buzzerPin, frequency, 500);
delay(100);
noTone(buzzerPin);
}
void displayDotMatrix(String text) {
for (int i = 0; i < text.length(); i++) {
char character = text.charAt(i);
int asciiValue = character;
lc.setChar(0, i, asciiValue, false);
}
}