This is a very similar example to our ATMEGA16 and LCD example. We simply connect our 16×2 LCD display to our Attiny2313 PORTB. Again for simplicity the code is written in MikroC PRO for AVR.
We actually added and LCD breakout to our Attiny2313 development/experimenting board
Schematic
Code
[c]
sbit LCD_RS at PORTB4_bit;
sbit LCD_EN at PORTB5_bit;
sbit LCD_D4 at PORTB0_bit;
sbit LCD_D5 at PORTB1_bit;
sbit LCD_D6 at PORTB2_bit;
sbit LCD_D7 at PORTB3_bit;
sbit LCD_RS_Direction at DDB4_bit;
sbit LCD_EN_Direction at DDB5_bit;
sbit LCD_D4_Direction at DDB0_bit;
sbit LCD_D5_Direction at DDB1_bit;
sbit LCD_D6_Direction at DDB2_bit;
sbit LCD_D7_Direction at DDB3_bit;
void main()
{
PORTB = 0;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,”Hello world”); //Write the word mikroC on the LCD
Delay_ms(300);
} // end main
[/c]
Links
5PCS ATTINY2313A