Mikroelektronika - View Topic - Alphanumeric Lc... : Alphanumeric LCD and Push Button

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

mikroElektronika View topic - Alphanumeric LC...

Login

http://www.mikroe.com/forum/viewtopic.php?f=8...

Register

FAQ

Search

It is currently 13 Nov 2014 16:39

View unanswered posts | View active topics


Board index Compilers mikroC Compilers mikroC PRO for PIC mikroC PRO for PIC General

All times are UTC + 1 hour

Alphanumeric LCD and Push Button


Page 1 of 1 [ 3 posts ]
Print view

Previous topic | Next topic

Author
akmalhilmi

Joined: 28 Apr 2012 03:14


Posts: 5

Message
Post subject: Alphanumeric LCD and Push Button

Posted: 28 Apr 2012 03:55

In this experiment we will work with alphanumeric LCD and push button.
Communication with LCD will be performed through 4-bits and connections is made as follows: D4 with RB0, D5 with RB1, D6 with RB2, D7 with RB3, RS with RB4 and EN with RB5.
The Push button is connected to PORT RA0 - RA4 (for increment). I cant make it. anyone can help me to solve it? i using PIC 16F877A. LCD

Code: Select all

// LCD module connections


sbit LCD_RS at RB4_bit;

// LCD_RS assigned to PORT RB4;

sbit LCD_EN at RB5_bit;

// LCD_EN assigned to PORT RB5;

sbit LCD_D4 at RB0_bit;

// LCD_D4 assigned to PORT RB0;

sbit LCD_D5 at RB1_bit;

// LCD_D5 assigned to PORT RB1;

sbit LCD_D6 at RB2_bit;

// LCD_D6 assigned to PORT RB2;

sbit LCD_D7 at RB3_bit;

// LCD_D7 assigned to PORT RB3;

sbit LCD_RS_Direction at TRISB4_bit;

// LCD_RS assigned to TRIS B4;

sbit LCD_EN_Direction at TRISB5_bit;

// LCD_EN assigned to TRIS B5;

sbit LCD_D4_Direction at TRISB0_bit;

// LCD_D4 assigned to TRIS B0;

sbit LCD_D5_Direction at TRISB1_bit;

// LCD_D5 assigned to TRIS B1;

sbit LCD_D6_Direction at TRISB2_bit;

// LCD_D6 assigned to TRIS B2;

sbit LCD_D7_Direction at TRISB3_bit;

// LCD_D7 assigned to TRIS B3;

// End LCD module connections


char text1[]="5c = ";

// text for line1;

char text2[]="10c= ";

// text for line1;

char text3[]="20c= ";

// text for line2;

char text4[]="50c= ";

// text for line2;

unsigned int number = 0;


char *digit = "00";
void Display_init()

// define display_init;

{
digit[0] = (number/10)%10 + 48;

// tens digit;

digit[1] = number%10 +48;

// unit digit;

Lcd_Out(1,6,digit);

// display on LCD from column 1, character 6;

Lcd_Out(1,14,digit);

// display on LCD from column 1, character 14;

Lcd_Out(2,6,digit);

// display on LCD from column 2, character 6;

Lcd_Out(2,14,digit);

// display on LCD from column 2, character 14;

}
void main()

// main;

{
CMCON |= 7;

// turn off analogue comparator and make PORTA to digital I/O;

TRISA = 1;

// make PORT RA6 as input for button;

TRISB = 0;

// Set PORTB direction to be output;

PORTB = 0;

// Turn ON PORTB;

Lcd_init();

// LCD Initialization;

Lcd_cmd(_LCD_CLEAR);

// Clear LCD;

Lcd_cmd(_LCD_CURSOR_OFF);

// Cursor mode, off;

Lcd_out(1,2,text1);

// display message1 from column 1, character 2;

Lcd_out(1,10,text2);

// display message1 from column 1, character 10;

Lcd_out(2,2,text3);

// display message1 from column 2, character 2;

Lcd_out(2,10,text4);

// display message1 from column 1, character 10;

while(1)
{
do{
if(Button(&PORTA,0,1,0)){
Delay_ms(200);

// If button is pressed, delay 0,2s and increment "number" with 1;

number = number +1;


}

1 of 3

11/13/2014 10:40 AM

mikroElektronika View topic - Alphanumeric LC...

http://www.mikroe.com/forum/viewtopic.php?f=8...

display_init();

// call display_init();

delay_ms(1000);

// delay 1s;

number ++;
if (number > 99u)

// Increment number;
// if it's more than 9999 go to 0;

number = 0;
} while(1);

// infinite loop;

}
}

Top
jtemples

Post subject: Re: Alphanumeric LCD and Push Button

Posted: 28 Apr 2012 18:12

Quote:
Joined: 22 Jan 2012 05:46
Posts: 258

I cant make it.

What is "it"?

Top
akmalhilmi

Post subject: Re: Alphanumeric LCD and Push Button

Posted: 29 Apr 2012 21:37

means i cant do it.


Joined: 28 Apr 2012 03:14
Posts: 5
Top
Display posts from previous:

All posts

Sort by

Post time

Ascending

Go

Page 1 of 1 [ 3 posts ]

Board index Compilers mikroC Compilers mikroC PRO for PIC mikroC PRO for PIC General

All times are UTC + 1 hour

Who is online
Users browsing this forum: Bing [Bot], pwdixon, qwall and 5 guests

You cannot post new topics in this forum


You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

2 of 3

11/13/2014 10:40 AM

mikroElektronika View topic - Alphanumeric LC...

Search for:

http://www.mikroe.com/forum/viewtopic.php?f=8...

Go

Jump to:

mikroC PRO for PIC General

Go

Powered by phpBB Forum Software phpBB Group

3 of 3

11/13/2014 10:40 AM

You might also like