📄 as5030.c
字号:
// LCD module connections
sbit LCD_RS at PORTB.B0;
sbit LCD_RW at PORTB.B7;
sbit LCD_EN at PORTB.B6;
sbit LCD_D4 at PORTD.B4;
sbit LCD_D5 at PORTD.B5;
sbit LCD_D6 at PORTD.B6;
sbit LCD_D7 at PORTD.B7;
sbit LCD_RS_Direction at DDRB.B0;
sbit LCD_EN_Direction at DDRB.B7;
sbit LCD_RW_Direction at DDRB.B7;
sbit LCD_D4_Direction at DDRD.B4;
sbit LCD_D5_Direction at DDRD.B5;
sbit LCD_D6_Direction at DDRD.B6;
sbit LCD_D7_Direction at DDRD.B7;
// End LCD module connections
char txt1[] = "mikroElektronika";
char txt2[] = "EasyAVR5A";
char txt3[] = "Lcd4bit";
char txt4[] = "example";
char i; // Loop variable
void Move_Delay()
{ // Function used for text moving
Delay_ms(500); // You can change the moving speed here
}
void main()
{ LCD_RW = 0;
LCD_RW_Direction = 1;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(LCD_CLEAR); // Clear display
Lcd_Cmd(LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,6,txt3); // Write text in first row
Lcd_Out(2,6,txt4); // Write text in second row
Delay_ms(2000);
Lcd_Cmd(LCD_CLEAR); // Clear display
Lcd_Out(1,1,txt1); // Write text in first row
Lcd_Out(2,4,txt2); // Write text in second row
Delay_ms(2000);
// Moving text
for(i=0; i<4; i++)
{ Lcd_Cmd(LCD_SHIFT_RIGHT); // Move text to the right 4 times
Move_Delay();
}
while(1)
{for(i=0; i<7; i++)
{ Lcd_Cmd(LCD_SHIFT_LEFT); // Endless loop
Move_Delay(); // Move text to the left 7 times
}
for(i=0; i<7; i++)
{Lcd_Cmd(LCD_SHIFT_RIGHT); // Move text to the right 7 times
Move_Delay();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -