vead
Full Member level 5
Hello
I have written this program to display the numbers on screen
I don't understand this part of program. I don't understand what does program do in main function
arrays are declared and initialize in the following form
I understand what is array
I don't understand how does program work in main function. what is meaning of this line lcd_data(number[l]);?
I have written this program to display the numbers on screen
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 #include<reg51.h> #define display_port P1 //Data pins connected to port 2 on microcontroller sbit rs = P2^0; //RS pin connected to pin 2 of port 3 sbit rw = P2^1; // RW pin connected to pin 3 of port 3 sbit e = P2^2; //E pin connected to pin 4 of port 3 void main() { unsigned int number[15]="012345"; . int l=0; lcd_init(); while(number[l] != '\0') { lcd_data(number[l]); l++; msdelay(50); } } void msdelay(unsigned int time) // Function for creating delay in milliseconds. { unsigned i,j ; for(i=0;i<time;i++) for(j=0;j<1275;j++); } void lcd_cmd(unsigned char command) //Function to send command instruction to LCD { display_port = command; rs= 0; rw=0; e=1; msdelay(1); e=0; } void lcd_data(unsigned char disp_data) //Function to send display data to LCD { display_port = disp_data; rs= 1; rw=0; e=1; msdelay(1); e=0; } void lcd_init() //Function to prepare the LCD and get it ready { lcd_cmd(0x38); // for using 2 lines and 5X7 matrix of LCD msdelay(10); lcd_cmd(0x0c); // turn display ON, cursor blinking msdelay(10); lcd_cmd(0x01); //clear screen msdelay(10); lcd_cmd(0x81); // bring cursor to position 1 of line 1 msdelay(10); }
I don't understand this part of program. I don't understand what does program do in main function
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 void main() { unsigned int number[15]="012345"; int l=0; lcd_init(); while(number[l] != '\0') { lcd_data(number[l]); l++; msdelay(50); } }
arrays are declared and initialize in the following form
Code:
unsigned int number[15]="012345";
Code:
number[0] = 0
number[1]= 1
number[2] = 2
number[3] = 3
number[5] = 4
number[6] = 5
number[7]
number[8]
number[9]
number[10]
number[11]
number[12]
number[13]
number[14]
number[15]
I don't understand how does program work in main function. what is meaning of this line lcd_data(number[l]);?