Microcontroller › 8051 › Matrix display
- This topic has 8 replies, 2 voices, and was last updated 13 years, 7 months ago by dagakshay.
-
AuthorPosts
-
May 12, 2011 at 7:59 pm #927FARRUKHParticipant
I’ve assigned to make a project of two 2×2 matrix operation circuit i.e addition,subtraction,etc and I’ve completed its LCD interfacing and able to display 1st matrix.But I want to know that how can I save that matrix so that I can take another matrix from keypad and proceed the operations i.e addition,subtraction & multplication.
May 13, 2011 at 7:43 am #6183dagakshayParticipanthello Farrukh.
just declare Two array in RAM/ use can also use External EEPROM… or use comtrollers like AVR which has inbuilt EEPROM… the part you asking is more of algoritum side… first discuss on algo later you can make codes …whats your algo to do that…
May 13, 2011 at 4:22 pm #6188FARRUKHParticipantI’m using 8051 microcontroller and my programming is in C
I want to save matrix in same controller in array form
May 14, 2011 at 3:36 am #6193dagakshayParticipantjust create a 2 dimensinal array as you do in c langauge…. i am not getting what difficulty you facing here
May 14, 2011 at 7:33 am #6195FARRUKHParticipantI’m tryring to create an array but getting some errors
May 14, 2011 at 10:02 am #6197dagakshayParticipantpost the error… i do that and i never got an eroor doing so. aslo past the code line in which you declared the 2d array…
May 14, 2011 at 1:37 pm #6200FARRUKHParticipant#include<reg51.h>
sbit rs = P3^0;
sbit rw = P3^1;
sbit en = P3^2;
sbit busy = P2^7;
#define TRUE 1
#define FALSE 0void lcdready();
void clearscreen();
void lcdcmd(unsigned char value);
void lcddata(unsigned char value);
void lcdinitialize(void);
void lcddisplay(char str[], unsigned int k);
unsigned int keydetect (void);
char numdetect(char i);
void operate(char i);
void numprint(long float i);sbit col0 = P1^0;
sbit col1 = P1^1;
sbit col2 = P1^2;
sbit col3 = P1^3;unsigned char num1;
unsigned int j=16;
unsigned char str[]=”enter 2nd matrix”;
int c=0;
int d=0;char sign=0;
char co,lo=0;void main()
{
char i;
int p=0;
unsigned int j=16;unsigned char str[] = “enter 1st matrix”;
unsigned char a[2][2];
int k,m;lcdinitialize();
lcddisplay(str, j);while(1)
{
i=keydetect ();
p++;if(i!=0){
numdetect(i);
a[0][0]=num1;
if(p==1){
k=a[0][0];
lcddata(k);}
}
}return ;
}void lcdready()
{
busy = 1;
rs = 0;
rw = 1;
en = 0;
en = 1;
while(busy==1)
{
en = 0;
en = 1;
}
return;
}
void lcdcmd(unsigned char value)
{
lcdready();
P2 = value;
rs = 0;
rw=0;
en=1;
en=0;
return;
}void lcddata(unsigned char value)
{
lcdready();P2 = value;
rs = 1;
rw=0;
en=1;
en=0;
return;
}
void lcdinitialize(void)
{
lcdcmd(56);
lcdcmd(14); // display on, cursor blinking
lcdcmd(1);
lcdcmd(6);
lcdcmd(0x80); //line 1, position 0
}void lcddisplay(char str[], unsigned int k)
{
unsigned int i;
for(i=0; i<k; i++)
lcddata(str);
}unsigned int keydetect (void){
unsigned char key=0;
char i;
for (i=0; i<4; i++){
P1 &= ~(0x80>>i);if(col0 == 0){
key = P1;
while(col0 == 0);return key;
}
if(col1 == 0){
key = P1;
while(col1 == 0);return key;
}
if(col2 == 0){
key = P1;
while(col2 == 0);return key;
}
if(col3 == 0){
key = P1;
while(col3 == 0);return key;
}P1 |= (0x80>>i);
}
return 0;
}char numdetect(char var)
{
switch (var)
{
case 0xEE:
lcddata(‘7’);
num1 =7;
lcdcmd(0x14);
c++;
if(c==2){
lcdcmd(0xC0);
c=0; }
break;case 0xED:
lcddata(‘8’);
num1=8;
lcdcmd(0x14);
c++;
if(c==2){
lcdcmd(0xC0);
c=0;}
break;case 0xEB:
lcddata(‘9’);
num1=9;
lcdcmd(0x14);
c++;
if(c==2){
lcdcmd(0xC0);
c=0;}
break;case 0xDE:
lcddata(‘4’);
num1=4;
lcdcmd(0x14);
c++;
if(c==2){
lcdcmd(0xC0);
c=0;}
break;case 0xDD:
lcddata(‘5’);
num1=5;
lcdcmd(0x14);
c++;
if(c==2){
lcdcmd(0xC0);
c=0;}
break;case 0xDB:
lcddata(‘6’);
num1=6;
lcdcmd(0x14);
c++;
if(c==2){
lcdcmd(0xC0);
c=0;}
break;case 0xBE:
lcddata(‘1’);
num1=1;
lcdcmd(0x14);
c++;
if(c==2){
lcdcmd(0xC0);
c=0;}
break;case 0xBD:
lcddata(‘2’);
num1=2;
lcdcmd(0x14);
c++;
if(c==2){
lcdcmd(0xC0);
c=0;}
break;case 0xBB:
lcddata(‘3’);
num1=3;
lcdcmd(0x14);
c++;
if(c==2){
lcdcmd(0xC0);
c=0;}
break;case 0x7D:
lcddata(‘0’);
num1=0;
lcdcmd(0x14);
c++;
if(c==2){
lcdcmd(0xC0);
c=0;
break;case 0x7E:
clearscreen();num1=-1;
break;
case 0x7B:
lcddisplay(str,j);
num1=-1;
break;}
return num1;
}
}void clearscreen( void )
{
unsigned int i;
lcdcmd(0x01);return;
}May 16, 2011 at 4:56 am #6209dagakshayParticipantno code discription, no ckt, no code comments, before ypu you gettign error in code you dint even posted those error. how you tell me farrukh how to solve your problem and how to understand your code?
May 16, 2011 at 4:58 am #6210dagakshayParticipantpost the error and if possible a bit of code comments and descriptions
-
AuthorPosts
- You must be logged in to reply to this topic.