karthi06
Junior Member level 2
- Joined
- Jan 16, 2014
- Messages
- 24
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 209
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 // Lcd pinout settings sbit LCD_RS at RB0_bit; sbit LCD_EN at RB1_bit; sbit LCD_D4 at RB2_bit; sbit LCD_D5 at RB3_bit; sbit LCD_D6 at RB4_bit; sbit LCD_D7 at RB5_bit; // Pin direction sbit LCD_RS_Direction at TRISB0_bit; sbit LCD_EN_Direction at TRISB1_bit; sbit LCD_D4_Direction at TRISB2_bit; sbit LCD_D5_Direction at TRISB3_bit; sbit LCD_D6_Direction at TRISB4_bit; sbit LCD_D7_Direction at TRISB5_bit; void main() { Lcd_Init(); Lcd_Out(1, 1, "Hello!"); Lcd_Cmd(_LCD_CURSOR_OFF); }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 // Lcd pinout settings sbit LCD_RS at RB0_bit; sbit LCD_EN at RB1_bit; sbit LCD_D4 at RB2_bit; sbit LCD_D5 at RB3_bit; sbit LCD_D6 at RB4_bit; sbit LCD_D7 at RB5_bit; // Pin direction sbit LCD_RS_Direction at TRISB0_bit; sbit LCD_EN_Direction at TRISB1_bit; sbit LCD_D4_Direction at TRISB2_bit; sbit LCD_D5_Direction at TRISB3_bit; sbit LCD_D6_Direction at TRISB4_bit; sbit LCD_D7_Direction at TRISB5_bit; void main() { TRISB = 0x00; PORTB = 0x00; Lcd_Init(); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "Hello!"); while(1){ } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 TRISD = 0x01; PORTD = 0x00; while(1){ if(PORTD.F0){ Delay_ms(50); if(PORTD.F0){ PORTD.F1 = 0; LCD_Out(2,1,"No Detect"); } } else if(!PORTD.F0){ Delay_ms(50); if(!PORTD.F0){ PORTD.F1 = 1; LCD_Out(2,1,"Detect "); } } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 // Lcd pinout settings sbit LCD_RS at RB0_bit; sbit LCD_EN at RB1_bit; sbit LCD_D4 at RB2_bit; sbit LCD_D5 at RB3_bit; sbit LCD_D6 at RB4_bit; sbit LCD_D7 at RB5_bit; // Pin direction sbit LCD_RS_Direction at TRISB0_bit; sbit LCD_EN_Direction at TRISB1_bit; sbit LCD_D4_Direction at TRISB2_bit; sbit LCD_D5_Direction at TRISB3_bit; sbit LCD_D6_Direction at TRISB4_bit; sbit LCD_D7_Direction at TRISB5_bit; char txt1[] = "999"; char txt2[] = "012-3456789"; char txt3[] = "013-3456789"; char txt4[] = "014-3456789"; 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 while(1) { Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,1,txt1); // Write text in first row Lcd_Out(2,1,txt2); // Write text in second row Delay_ms(3000); // Moving text for(i=0; i<11; i++) { // Move text to the right 11 times Lcd_Cmd(_LCD_SHIFT_RIGHT); Move_Delay(); } for(i=0; i<11; i++) { // Move text to the left 11 times Lcd_Cmd(_LCD_SHIFT_LEFT); Move_Delay(); } Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Out(1,1,txt3); // Write text in first row Lcd_Out(2,1,txt4); // Write text in second row Delay_ms(3000); // Moving text for(i=0; i<11; i++) { // Move text to the right 11 times Lcd_Cmd(_LCD_SHIFT_RIGHT); Move_Delay(); } for(i=0; i<11; i++) { // Move text to the left 11 times Lcd_Cmd(_LCD_SHIFT_LEFT); Move_Delay(); } } } TRISD = 0x01; PORTD = 0x00; while(1){ if(PORTD.F0){ Delay_ms(50); if(PORTD.F0){ PORTD.F1 = 0; LCD_Out(2,1,"No Detect"); } } else if(!PORTD.F0){ Delay_ms(50); if(!PORTD.F0){ PORTD.F1 = 1; LCD_Out(2,1,"Detect "); } } } } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 // Lcd pinout settings sbit LCD_RS at RB0_bit; sbit LCD_EN at RB1_bit; sbit LCD_D4 at RB2_bit; sbit LCD_D5 at RB3_bit; sbit LCD_D6 at RB4_bit; sbit LCD_D7 at RB5_bit; // Pin direction sbit LCD_RS_Direction at TRISB0_bit; sbit LCD_EN_Direction at TRISB1_bit; sbit LCD_D4_Direction at TRISB2_bit; sbit LCD_D5_Direction at TRISB3_bit; sbit LCD_D6_Direction at TRISB4_bit; sbit LCD_D7_Direction at TRISB5_bit; char txt1[] = "999"; char txt2[] = "012-3456789"; char txt3[] = "013-3456789"; char txt4[] = "014-3456789"; char i, j; // Loop variable void Move_Delay() { // Function used for text moving Delay_ms(500); // You can change the moving speed here } void main(){ TRISB = 0x00; PORTB = 0x00; TRISD = 0x01; PORTD = 0x00; Lcd_Init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,1,txt1); // Write text in first row Lcd_Out(2,1,txt2); // Write text in second row Delay_ms(3000); for(j = 0; j < 2; j++){ // Moving text for(i=0; i<11; i++) { // Move text to the right 11 times Lcd_Cmd(_LCD_SHIFT_RIGHT); Move_Delay(); } for(i=0; i<11; i++) { // Move text to the left 11 times Lcd_Cmd(_LCD_SHIFT_LEFT); Move_Delay(); } Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Out(1,1,txt3); // Write text in first row Lcd_Out(2,1,txt4); // Write text in second row Delay_ms(3000); } while(1){ if(PORTD.F0){ Delay_ms(50); if(PORTD.F0){ PORTD.F1 = 0; LCD_Out(2,1,"No Detect"); } } else if(!PORTD.F0){ Delay_ms(50); if(!PORTD.F0){ PORTD.F1 = 1; LCD_Out(2,1,"Detect "); } } } }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?