#include <LiquidCrystal.h>
// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Seven-segment display pin definitions
int segmentPins[] = {6, 7, 8, 9, 10, 13, A0, A1}; // Including DP pin
void setup() {
// Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Set up the seven-segment display pins as outputs
for (int i = 0; i < 8; i++) {
pinMode(segmentPins[i], OUTPUT);
}
}
void loop() {
// Display on the LCD
lcd.setCursor(0, 0);
lcd.print("Hello, World!");
// Display on the Seven-Segment Display with DP
displayDigitWithDP(8, true); // Display the digit 8 with DP
delay(2000); // Display for 2 seconds
}
// Function to display a digit on the Seven-Segment Display with DP
void displayDigitWithDP(int digit, boolean dp) {
// Define the seven-segment display patterns for each digit from 0 to 9
byte patterns[10][8] = {
{1, 1, 1, 1, 1, 1, 0, 0}, // 0 with DP
{0, 1, 1, 0, 0, 0, 0, 0}, // 1 with DP
// ... other patterns for digits 2 through 9
};
// Set the DP pin
digitalWrite(segmentPins[7], dp);
// Display the corresponding pattern on the seven-segment display
for (int i = 0; i < 7; i++) {
digitalWrite(segmentPins[i], patterns[digit][i]);
}
}