??? 06/29/06 19:27 Read: times |
#119366 - 2 Responding to: ???'s previous message |
//I alos tried it...but u know i am beginner...this code is not logically write.i dont understand what to do knwo.....
#include <ATMEL/AT89X51.H> void wait(void); sbit column1=P1^4; sbit column2=P1^5; sbit column3=P1^6; sbit row1=P1^0; sbit row2=P1^1; sbit row3=P1^2; sbit row4=P1^3; void rowscan(void); void main(void) { while(1) { P1=0x0F; if (row1==0||row2==0 ||row3==0 || row4==0) { rowscan(); } } } void rowscan(void) { int a[4]={0,0,0,0},t=0,k,r,m=100; static int sum=0; if (column1==0 && row1==0) { a[t]=1; } if (column2==0 && row1==0) { a[t]=2; } if (column3==0 && row1==0) { a[t]=3; } if (column1==0 && row2==0) { a[t]=4; } if (column2==0 && row2==0) { a[t]=5; } if (column3==0 && row2==0) { a[t]=6; } if (column1==0 && row3==0) { a[t]=7; } if (column2==0 && row3==0) { a[t]=8; } if (column3==0 && row3==0) { a[t]=9; } if (column1==0 && row4==0) { a[t]=15; } if (column2==0 && row4==0) { a[t]=0; } if (column3==0 && row4==0) { a[t]=16; } t++; for (k=0;k<3;k++) { if (a[k]==15) { r=0; while (a[r]!=15 && r<4) { P2=0; sum=sum+m*a[k]; m=m/10; r++; } } } if (sum>0) { P2=sum; } wait(); } void wait(void) { int f =0; while (f<33000) { f++; } } |