Archives
-
Help needed keypad & LCD. Please..
Hi,
I want to interface a 4×4 keypad to my philips microcontroller. The keys I enter should be displayed on LCD.
The key 1 for ex: if pressed once it should return ‘a’ and when pressed twice it should return ‘b’ and simillarly ‘c’ the third time. Just like in phones.I have a code in C below, I tried but its not working. The connections are perfect. Please help me out here.. Thanks in advance.
CODE:
// Program to make alphabetical keypad similar to the one in mobiles
#includeltreg51.hgt
#include ltstring.hgt
#include ltstdio.hgt#define port P1
#define dataport P2 //Data port for LCD
#define key P0 // Port for Keypad
#define sec 100
sbit rs = port^1;
sbit rw = port^2;
sbit en = port^3;sbit col1=key^4;
sbit col2=key^5;
sbit col3=key^6;
sbit row1=key^0;
sbit row2=key^1;
sbit row3=key^2;
sbit row4=key^3;
unsigned char position=128,i=0;
int check_again[10]={0,0,0,0,0,0,0,0,0,0};void delay(unsigned int msec);
void lcd_cmd(unsigned char item);
void lcd_data(unsigned char item);
void num_check(int a , int b);
void display(int a ,int b);void delay(unsigned int msec) // Time delay function
{
int i,j ;
for(i=0;iltmsec;i++)
for(j=0;jlt1275;j++);
}void lcd_cmd(unsigned char item)
{
dataport = item;
rs= 0;
rw=0;
en=1;
delay(1);
en=0;
return;
}void lcd_data(unsigned char item)
{
lcd_cmd(0x0f);
delay(10);
dataport = item;
rs= 1;
rw=0;
en=1;
delay(1);
en=0;
return;
}void num_check(int a , int b) //Check function
{
int j;
for(j=0;jlt10;j++)
{
if(j!=a)
{
check_again[j]=0;
}
}
if(check_again[a]==3)
check_again[a]=0;
check_again[11]=1;
check_again[12]=1;
}void display(int a ,int b) // Display function
{
switch(b)
{
case 1:
{
switch(a)
{
case 1:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘a’);
delay(5);
num_check(1 ,check_again[1]);
break;
}
case 2:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘d’);
delay(5);
num_check(2 ,check_again[2]);
break;
}
case 3: {
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘g’);
delay(5);
num_check(3 ,check_again[3]);
break;
}
case 4:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘j’);
delay(5);
num_check(4 ,check_again[4]);
break;
}
case 5:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘m’);
delay(5);
num_check(5 ,check_again[5]);
break;
}
case 6:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘p’);
delay(5);
num_check(6 ,check_again[6]);
break;
}
case 7:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘s’);
delay(5);
num_check(7 ,check_again[7]);
break;
}
case 8:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘v’);
delay(5);
num_check(8 ,check_again[8]);
break;
}
case 9:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘y’);
delay(5);
num_check(9 ,check_again[9]);
break;
}
case 0:{
lcd_cmd(position+i);
lcd_data(‘ ‘);
delay(5);
num_check(10 ,check_again[10]);
break;
}
case 11:{
if((position+i)gt129)
{
i=i-2;
delay(5);
lcd_cmd(position+i+1);
num_check(11 ,check_again[11]);;
delay(5);
}
break;
}
case 12:{
delay(5);
lcd_cmd(position+i);
num_check(12 ,check_again[12]);
delay(5);
break;
}
}
break;
}
case 2:
{
switch(a)
{
case 1:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘b’);
delay(5);
num_check(1 ,check_again[1]);
break;
}
case 2:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘e’);
delay(5);
num_check(2 ,check_again[2]);
break;
}
case 3: {
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘h’);
delay(5);
num_check(3 ,check_again[3]);
break;
}
case 4:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘k’);
delay(5);
num_check(4 ,check_again[4]);
break;
}
case 5:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘n’);
delay(5);
num_check(5 ,check_again[5]);
break;
}
case 6:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘q’);
delay(5);
num_check(6 ,check_again[6]);
break;
}
case 7:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘t’);
delay(5);
num_check(7 ,check_again[7]);
break;
}
case 8:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘w’);
delay(5);
num_check(8 ,check_again[8]);
break;
}
case 9:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘z’);
delay(5);
num_check(9 ,check_again[9]);
break;
}
case 0:{
lcd_cmd(position+i);
lcd_data(‘-’);
num_check(10 ,check_again[10]);
break;
}
case 11:{
i–;
lcd_cmd(0×10);
delay(5);
break;
}
}
break;
}
case 3:
{
switch(a)
{
case 1:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘c’);
delay(5);
num_check(1 ,check_again[1]);
break;
}
case 2:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘f’);
delay(5);
num_check(2 ,check_again[2]);
break;
}
case 3: {
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘i’);
delay(5);
num_check(3 ,check_again[3]);
break;
}
case 4:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘l’);
delay(5);
num_check(4 ,check_again[4]);
break;
}
case 5:{
if(check_again[a]gt1)
i–;
lcd_cmd(position+i);
lcd_data(‘o’);
delay(5);
num_check(5 ,check_again[5])SPAN stRelated Forum Messages
- Help me with this code
- [SOLVED] Cant understand a code snippet
- How to read philips remote data interface with 8051
- Lcd interfacing with 8051 microcontroller
- Sms tranmission through GSM MODEM 8051
- LCD Interfacing with 8051
- 16F628A Uart & LCD
- Unable to find mistake in program….if u could help?
- I have a problem in conservation through the EEPROM
- Help me pleeeease (LCD Digital clock)
- [SOLVED] LCD interfacing with 8051
- [SOLVED] problem in interfacing graphical LCD using LPC2138
- LPC2148 4×4 Matrix Keypad Issue
- LCD display flickrign problem. Urgent help required.
- [SOLVED] LCD display flickrign problem. Urgent help required.
- [SOLVED] my quiz with my kepad !!! plz help me
- Getting error of multiple public defination.
- HELP !! with Digital Lock
- ADC0808 channel selection and interferance between channels problem.
- 16×2 Alphanumeric LCD with LPC2138.
Code: // Program to interface Sharps distance sensor. Set vref =3v for ADC0804 #include<reg51.h> #define port P3 #define adc_input P1 #define dataport P0 #define sec 100 sbit rs = port^0; sbit rw = port^1; sbit e = port^2; sbit wr= port^3; sbit rd= port^4; sbit intr= port^5; int test_final=0 ,shift=0; void delay(unsigned int msec ) { int i ,j ; for(i=0;i<msec;i++) for(j=0; j<1275; j++); } void lcd_cmd(unsigned char item) // Function to send command to LCD { dataport = item; rs= 0; rw=0; e=1; delay(1); e=0; return; } void lcd_data(unsigned char item) // Function to send data to LCD { dataport ...Hello everybody i hope all of you are doing fine..Well coming to my problem I am designing a digital thermometer using lm35, adc 0804 and 89s52 microcontroller. I went throught the whole coding and understood all the parts except one part. the whole code is as follows: Code: /* #include<regx52.h> #define port P3 #define adc_input P1 #define dataport P2 #define sec 100 sbit rs = port^0; sbit rw = port^1; sbit e = port^2; sbit wr= port^3; sbit rd= port^4; sbit intr= port^5; sbit set= port^6; int test_intermediate3=0, test_final=0,test_intermediate1[10],test_intermediate2[3]={0,0,0}, setpt = 25; void delay(unsigned int msec ) { int i ,j ; for(i=0;i<msec;i++) for(j=0; j<1275; j++); } void lcd_cmd(unsigned char item) //Function to send command to LCD { dataport = item; rs= 0; rw=0; e=1; delay(1); e=0; return; } void lcd_data(unsigned ...I have designed and written some code to display the recievers output on lcd but not getting the required output can anyone help me #includeltreg51.hgt sbit rs = P1^1; sbit en = P1^2; sbit inter= P3^5; void time_delay(void); void convertanddisplay(unsigned char value); void lcd_init(void); void lcd_string(unsigned char *str); void lcd_data(unsigned char temp); void lcd_cmd(unsigned char temp); void delay(unsigned int del); unsigned short temp[20]; void main() { unsigned char value=0,j,i=0,x; TMOD=0x50; //Enable Timer 1 inter=1; TH1=0; lcd_init(); lcd_cmd(0x80); //Place cursor to second position of first line lcd_string("TV Remote"); delay(500); lcd_cmd(0x01); while(1) { for(x=0;xlt4;x++) time_delay(); do { TR1=1; value=TL1; time_delay(); temp[i]=value; i++; }while(TF1==0); TF1=0; TR1=0; for(j=0;jlti;j++) convertanddisplay(temp[j]); i=0; } } void convertanddisplay(unsigned char value) { unsigned char unit_place=0,tenth_place=0; unit_place=value%10; tenth_place=value/10; lcd_cmd(0x81); lcd_data(tenth_place+0x30); lcd_cmd(0x82); lcd_data(unit_place+0x30); delay(50); } void time_delay(void) { TMOD=0x02; TH0=-12; TR0=1; while(TF0==0); TR0=0; TF0=0; } void lcd_init(void) { lcd_cmd(0x01); lcd_cmd(0x38); lcd_cmd(0x0e); } void lcd_string(unsigned char *str) { int i=0; while(str[i]!='\0') { lcd_data(str[i]); i++; delay(10); } } void lcd_data(unsigned char temp) { P2=temp; rs= 1; en=1; delay(20); en=0; } void lcd_cmd(unsigned char temp) { P2=temp; rs= 0; en=1; delay(20); en=0; } void delay(unsigned int del) { int i,j ; for(i=0;iltdel;i++) for(j=0;jlt1275;j++); }how to interface lcd with 8051?............... ---------- Post added at 12:46 ---------- Previous post was at 12:46 ---------- #include ltREGX51.Hgt sbit rs=P3^5; sbit rw=P3^6; sbit en=P3^7; delay(unsigned int i) { while(i--); } lcd_cmd(unsigned char c) { P1=c; rs=0; rw=0; en=1; delay(150); en=0; } lcd_data(unsigned char c) { P1=c; rs=1; rw=0; en=1; delay(150); en=0; } lcd_init() { lcd_cmd(0x38); lcd_cmd(0x0c); lcd_cmd(0x01); lcd_cmd(0x80); } void main() { int i; lcd_init(); for(i=0;ilt=16;i++) { lcd_cmd(0x01); lcd_cmd(0x80+i); lcd_data( "VINOTH"); } lcd_cmd(0xc0); lcd_data( " HELLO World"); }i need help. i have run the below code sucessfully in proteus ....but stuck in my matrix circuit ....can any1 give any details why the msg is not transmitting . can any1 give simple msg sending code or edit the below code. ...Hello everyone I write a simple code to interface LCD with 8051, this will show your name on LCD Here is code CODE: #include ltREGX51.Hgt sbit rs=P1^0; sbit rw=P1^1; sbit E=P1^2; void LCD_data(unsigned char x); void LCD_cmd(unsigned char x); void delay_ms(unsigned int x); void main(){ delay_ms(200); LCD_cmd(0x38); ...Hello I am a bit stuck with the lower code. using a PIC16F628A with an internal oscillator: CONFIG: $ 2007: 0x217B When copmile, and try to PIC Simulator IDE is ok, but when I try connect HDW-programmed PIC amp LCD on my protoboard not working. Where did I go wrong , Code: Select all // LCD module connections sbit LCD_RS at RB0_bit; sbit LCD_EN at RB3_bit; sbit LCD_D4 at RA0_bit; sbit LCD_D5 at RA1_bit; sbit LCD_D6 at RA2_bit; sbit LCD_D7 at RA3_bit; sbit LCD_RS_Direction at TRISB0_bit; sbit LCD_EN_Direction at TRISB3_bit; sbit LCD_D4_Direction at TRISA0_bit; sbit LCD_D5_Direction at TRISA1_bit; sbit LCD_D6_Direction at TRISA2_bit; sbit LCD_D7_Direction at TRISA3_bit; void main() { char buff; CMCON=0b00000111; // turn ANALOG comparitors off UART1_Init(9600); Delay_ms(100); Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); ...Below is the program for moving message on lcd.....ws not working on chip....if u can help me any modifications..it is for philips P89v51rd2fn lcd is jhd162a #includeltreg51.hgt sfr lcd_data_pin=0x90; // port 1 sbit rs=P3^0; // Register select pin sbit rw=P3^1; // Read write pin sbit en=P3^2; // Enable pin void delay(unsigned int msec) //delay function { int i,j; for(i=0;iltmsec;i++) for(j=0;jlt1275;j++); } void lcd_cmd(unsigned char comm) // function to send command to LCD { lcd_data_pin=comm; en=1; rs=0; rw=0; delay(25); en=0; } void lcd_data(unsigned char disp) // function to send data on LCD { lcd_data_pin=disp; en=1; rs=1; rw=0; delay(25); en=0; } void lcd_puts(unsigned char *s) // function to send string to LCD { while(*s!='\0') { lcd_data(*s); s++; } } void lcd_ini() //Function to initialize the LCD { lcd_cmd(0x38); lcd_cmd(0x06); lcd_cmd(0x80); lcd_cmd(0x01); lcd_cmd(0x0C); } void main() { ...I want to circle through the keyboard write a specific value After that I want to save these are value through EEPROM Then I recalled the value and these are displayed on the LCD Code: Select all sbit LCD_RS at RB4_bit; sbit LCD_EN at RB5_bit; sbit LCD_D4 at RB0_bit; sbit LCD_D5 at RB1_bit; sbit LCD_D6 at RB2_bit; sbit LCD_D7 at RB3_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB0_bit; sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; char keypadPort at PORTD ; char kp ,save; void main() { while(1) { lcd_init(); Keypad_Init(); lcd_out(1,1,"TECNOLOGY EXPERS"); delay_ms(2000); Lcd_Cmd(_LCD_CLEAR); lcd_cmd(_lcd_cursor_off); lcd_out(1,1,"Value:") ; lcd_cmd(_LCD_SECOND_ROW); lcd_cmd(_lcd_underline_on); do {kp = keypad_key_click() ; } while (!kp); switch (kp) { case 1: kp = 49; ...hi guys plzzzz help me with my project name: LCD Digital clock using AT89C51 i have connect the whole circuit and i have a C++ code my instructor want an assembly code for this project plzzz help me to convert the C++ code to assembly Circuit diagram: http://www.engineersgarage.com/conte...0AT89C51_0.gif C code: PHP Code: #includeltreg51.hgt #define cont_port P3 #define port P1 #define dataport P2 // Data port for LCD #define m_sec 10 sbit rs = cont_port^0; sbit rw = cont_port^1; sbit en = cont_port^6; sbit dig_hr1=port^0; sbit dig_min1=port^1; sbit start=port^2; sbit am_pm=port^3; int hr ,hr1=0; int min,min1=0; int sec,sec1=0,dig_am_pm=0; void delay(unsigned int msec) // Time delay ...hello mates; I have written the code for displaying characters on 16*2 LCD with 8051 in C language (in 8 bit mode); however i could not see any output on my Proteus simulator. I checked my code again and again, can i have your expert looks please... thanks amp regards, Pravin B here is code::::::::: Code: #include<REG51.H> sbit rs=P0^0; //rs connected to p0.0 sbit rw=P0^1; //rw connected to p0.1 sbit en=P0^2; //en connected to p0.2 sbit busy=P2^7; //busy connected to p2.7 void delay(unsigned int count) //delay subroutine { unsigned int i,j; for(i=0;i<=count;i++) for(j=0;j<=1275;j++); } void ready() //subroutine to check if lcd is busy { busy=1; //make busy pin input rs=0; //rs=low rw=1; //rw=high while(busy==0) //check if busy flag is equal to 0 { en=0; delay(2); en=1; } } void lcd_cmd(unsigned int value) //sub. to write commands { ready(); P2=value; rs=0; rw=0; en=1; delay(2); en=0; } void lcd_data(unsigned int value) //sub to write ...hello, i am interfacing graphical LCD with LPC2138 micro controller. but their is a some problem genrating in my code, due to this i am unable to interface my LCD. I am attaching my code amp proteus file with this post. please help me to remove my problem.. Code: #include<LPC213X.H> #define RST 4 #define E 5 #define RW 6 #define DI 7 #define CS1 8 #define CS2 9 #define LED 18 void lcd_cmd(unsigned char); void lcd_data(unsigned char); void lcd_inilize(); void shift(int); void delay(unsigned int); void display(); void page_address(int); void column_address(int); void left_side(int,char); void right_side(int,char); void clear_screen(); void start_line(int); /*const unsigned char truck[1024] = { 0, 0, 0, 0, 0, 0, 0, ...i m a M.Sc Electronics Student and now i have been told to interface the keypad on the Dev kit the board is Called Spirit II from Oasis, it has a LPC2148. the keypad is a matrix keypad. now whats done here is, its connected to a resistor array and the resistor array has a Vcc given to it. so. when i make the rows as input and columns as output the rows become high by default if the columns are made input they become high by default Algorithm Set Keypad pins to output initially clear the port so now, i make rows high read columns i mae columns high read ...Hi, i want to display data detected by ADC0808 on my 14x2 LCD but by doing this i am facing a problem that the data at my lcd display is not still to see as in Digital Multi-meters. here is the video link that shows my problem. i want to eliminate the flickring on screen. and here is my code. Code : #include <reg52.h> #define Port P2 // control port #define adc_input P1 #define data_port P0 // data from microcontroller to LCD #define sec 50 sbit ADC_A=Port^0; //ADC sbit ADC_B=Port^1; //ADC sbit RS=Port^7; //LCD sbit E=Port^5; //LCD ...Hi, i want to display data detected by ADC0808 on my 14x2 LCD but by doing this i am facing a problem that the data at my lcd display is not still to see as in Digital Multi-meters. here is the video link that shows my problem. i want to eliminate the flickring on screen. and here is my code. Code: #include <reg52.h> #define Port P2 // control port #define adc_input P1 #define data_port P0 // data from microcontroller to LCD #define sec 50 sbit ADC_A=Port^0; //ADC sbit ADC_B=Port^1; //ADC sbit RS=Port^7; //LCD sbit E=Port^5; //LCD sbit RW=Port^6; //LCD sbit ...hello ... simply i use 16f877 and keypad 4*3 for just display on lcd the num pressed. and this is keypad: http://dlnmh9ip6v2uc.cloudfront.net/.../Keypad1-L.jpg and my compiler i use is :mikroc pro for pic and my project is successfully working in proteus gtgtgt but in actual connection the lcd not display the correct number what i press!!!! i connect the keypad to portD like that: pin1gtgtgtgtRD0.....to 10k the GND pin2gtgtgtgtRD1.....to 10k the GND pin3gtgtgtgtRD2.....to 10k the GND pin4gtgtgtgtRD3 pin5gtgtgtgtRD4 pin6gtgtgtgtRD5 pin7gtgtgtgtRD6 so is my hardware connection wrong !!? ============= and my code here: Code: sbit LCD_RS at RB0_bit; sbit LCD_EN at RB1_bit; sbit LCD_D4 at RB4_bit; sbit LCD_D5 at RB5_bit; sbit LCD_D6 at RB6_bit; sbit LCD_D7 at RB7_bit; sbit ...I have done a program with keil,getting error while linking. but the same program is running in single file, i think problem with linking only...up to me,i linked the program..i dont know why is not linking...can any body suggest me. MAIN FILE:- #include ltREGX51.Hgt #include "lcd.c" unsigned int i=0,l=0; sbit alsen=P2^0; sbit eyesen=P2^2; sbit Buz=P0^2; sbit motor=P0^4; void timer_init() { IE=0x82; TMOD=0x01; TH0=0x4B; TL0=0xFD; TR0=1; } void main() { unsigned int j; lcd_init(); timer_init(); Buz=1; motor=1; delay(65000); delay(65000); while(1) { if(alsen==1) { lcd_cmd(0x80); lcd_str("Alcohol Detected"); lcd_cmd(0xc0); Buz = 0; motor=0; while(1); } else if(alsen==0) { lcd_cmd(0x80); for(j=0;jlt1000;j++); lcd_str("Alcohol Normal "); lcd_cmd(0xc0); } if(l==100) { if(igt20) { lcd_cmd(0xc0); ...Hey all, I'm working on digital lock project using PIC16F877A - LCD - 3x4 Keypad - programming in C. What I found really confused for me that how I can read the entered value by the keypad to check it later with saved password in my program Code: unsigned short key; // Keypad module connections char keypadPort at PORTD; // End Keypad module connections // LCD module connections sbit LCD_RS at RB4_bit; sbit LCD_EN at RB5_bit; sbit LCD_D4 at RB0_bit; sbit LCD_D5 at RB1_bit; sbit LCD_D6 at RB2_bit; sbit LCD_D7 at RB3_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB0_bit; sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; // End LCD ...hi friends, i am getting 3 analog signals at the inputs of ADC0808 and i am displaying it on LCD. they are voltage current and temperature signals. the problem is that when i vary one of the analog input it also effects the data from other inputs. that is if i vary voltage it resutls in the variation of voltage data, current data and temprature data on tha Screen of LCD. i tried my best to isolate it from each other by putting delays and clearing the arrays and data memory locations but the problem is as it is... please help ...Here we go, I just jumped from the world of 8-bit controllers to 32-bit. I did some basic led blinking programs and they went well. Then I started interfacing 16x2 LCD and I got no display in the Proteus simulation. If somebody got some minutes to spare here is my code, I just intend to write alphabet 'A' :) Code: //ARM_LCD_8.c //Author : Sierra Delta //Date : June 24 2012 //Test Code for interfacing 16x2 LCD with ARM uC in 8-bit mode. //Device : NXP LPC2138 //Date Modified : #include<lpc21xx.h> #define RS (1 << 25) #define RW (1 << 26) #define E (1 << 27) //Pins 0.16 ...
