void init_port(void);
void outdataF(char);
void outcontrolK(char);
void delay1(void);
void lcd_control_write(void);
void init_lcd(void);
void write_data(char);
void write_string(char);
void setup() {
// put your setup code here, to run once:
init_port();
init_lcd();
write_string("fuck you bitch");
}
void loop() {
// put your main code here, to run repeatedly:
}
void init_port(void) {
volatile char *dirF, *dirK;
dirF = (char *)0x30;
dirK = (char *)0x107;
*dirF = 0xff;
*dirK = 0x03;
}
void init_lcd(void) {
outdataF(0x38); // initialize the display in 8-bit mode, 2-line display, and 5x8 dot format
lcd_control_write();
outdataF(0x0f); // used to turn on the display and enable the cursor blinking.
lcd_control_write();
outdataF(0x01); // clear display
lcd_control_write();
outdataF(0x06); //sets the cursor to move to the right after each character, and the display shifts to the left.
lcd_control_write();
}
void outdataF(char out_data) {
volatile char *dataF;
dataF = (char *)0x31;
*dataF = out_data;
}
void lcd_control_write(void) {
outcontrolK(0x01); // Enable signal (E) set to high to latch the data
delay1(); // Delay to ensure the enable signal is stable
outcontrolK(0x00); // Enable signal (E) set to low
delay1(); // Delay before next operation
}
void outcontrolK(char out_ctrl) {
volatile char *dataK;
dataK = (char *)0x108;
*dataK = out_ctrl;
}
void write_string(char *ptr) {
while (*ptr != '\0') {
write_data(*ptr);
ptr++;
}
}
void write_data(char wr_data) {
outdataF(wr_data); // Send the data to be displayed on the LCD
outcontrolK(0x02); // Set the LCD to write mode (RS=1, RW=0)
delay1(); // Wait for a short delay (1 unit of delay, the exact duration depends on your delay function)
outcontrolK(0x03); // Enable the LCD (E=1)
delay1(); // Wait for a short delay
outcontrolK(0x02); // Disable the LCD (E=0)
delay1(); // Wait for a short delay
}
/*void write_data(char wr_data) {
outdataF(wr_data); // Send the data to be displayed on the LCD
outcontrolK(0x02); // Set the LCD to write mode (RS=1, RW=0)
lcd_control_write(); // Manage the enable signal and its delays
}*/
void delay1(void) {
delay(100);
}