Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Project name:
- Lcd_Test (Demonstration of the LCD library routines)
- * Copyright:
- (c) Mikroelektronika, 2009.
- * Revision History:
- 20080930:
- - initial release;
- - 20090818 - Slavisa Zlatanovic;
- * Description:
- This code demonstrates how the usage of the LCD 4-bit library. LCD is first
- initialized, then some text is written, then the text is moved.
- * Test configuration:
- MCU: ATmega16
- http://www.atmel.com/dyn/resources/prod_documents/doc2466.pdf
- Dev.Board: EasyAVR6
- http://www.mikroe.com/en/tools/easyavr6/
- Oscillator: External Clock 08.0000 MHz
- Ext. Modules: Character LCD 2x16
- http://www.mikroe.com/en/tools/components/#other
- SW: mikroC PRO for AVR
- http://www.mikroe.com/en/compilers/mikroc/avr/
- * NOTES:
- - Turn on the LCD backlight on the EasyAVR6 board (SW10.7).
- */
- // LCD module connections
- sbit LCD_RS at PORTD.B2;
- sbit LCD_EN at PORTD.B3;
- 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 DDRD.B2;
- sbit LCD_EN_Direction at DDRD.B3;
- 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[] = "EasyAVR6";
- 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_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++) { // Move text to the right 4 times
- Lcd_Cmd(_LCD_SHIFT_RIGHT);
- Move_Delay();
- }
- while(1) { // Endless loop
- for(i=0; i<7; i++) { // Move text to the left 7 times
- Lcd_Cmd(_LCD_SHIFT_LEFT);
- Move_Delay();
- }
- for(i=0; i<7; i++) { // Move text to the right 7 times
- Lcd_Cmd(_LCD_SHIFT_RIGHT);
- Move_Delay();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement