code description :
generating 200 random numbers and print it out on the first line of the (16x2) LCD ,while generating numbers if i pressed a push bottom i will save the current random numbe
r and put it in the second line ,
if i pressed the push bottom for the second time it will save another number and put it down into the second line and then for the third time pressing the push bottom,
after that if i i pushed another bottom it will stop the generation and print the 3 numbers in the LCD but by sorting (ascending or descending ) ,
******i make the code to generate that numbers and saving it but i cant make the code for the second bottom which will print out the 3 numbers ******
generating 200 random numbers and print it out on the first line of the (16x2) LCD ,while generating numbers if i pressed a push bottom i will save the current random numbe
C:
// LCD module connections
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;
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;
// End LCD module connections
void main(){
int i,num,num1,yy,x,num2,num3,count;
int num_save[5];
char conv[4];
int txt[5];
TRISB=0;
TRISD=255;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
for(count=0;count<50;count++){
num=rand();
bytetostr(num,conv);
lcd_out(1,1,conv);
delay_ms(500);
if(PORTD.B0==1){x++; i++ ;
saleh: if(PORTD.B0==1){goto saleh;}
if(x==1){
num_save[i]=conv;
lcd_out(2,1,num_save[1]);
}
if(x==2){num_save[i]=conv;
lcd_out(2,1,num_save[2]);
}
if(x==3){num_save[i]=conv;
lcd_out(2,1,num_save[3]);
}
}
delay_ms(250);
if(PORTD.B1==1){goto fin;}
}
fin:
Lcd_Cmd(_LCD_CLEAR);
lcd_out(2,1,num_save[1]);
lcd_out(2,1,num_save[2]);
lcd_out(2,1,num_save[3]);
}
if i pressed the push bottom for the second time it will save another number and put it down into the second line and then for the third time pressing the push bottom,
after that if i i pushed another bottom it will stop the generation and print the 3 numbers in the LCD but by sorting (ascending or descending ) ,
******i make the code to generate that numbers and saving it but i cant make the code for the second bottom which will print out the 3 numbers ******
Attachments
-
118.4 KB Views: 31
Last edited by a moderator: