OneForSorrow
Newbie level 2
Greetings fellows, as the title says I want to create a program that can read the input of keyboard matrix control and afterwards I want to pass the data in a display device (e.g 7-segment display or Led Matrix). I have tried but it was in vain, here is the code.Note that I am working in Phillips 8051 microcontroller and the compiler I use is Keil uVision.
Sorry for my bad English and bad format of the thread it is my first try.
Thank you for the time you've dedicated.:smile:
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 #include <stdio.h> //#include <reg51.h>//This is the library of Keil where the registers and port of 8051 are included and supported int main() { char input;//This is the input for our switch char P2; while(1)// An infinite loop in order to constantly get input for our code { scanf("%c",&input);//here we pass our input for our switch switch(input) { case '0' : P2=0x00;//P2 is the port where the data for almost every display device is destined break; case '1' : P2=0x01; break; case '2' : P2=0x02; break; case '3' : P2=0x03; break; case '4' : P2=0x04; break; case '5' : P2=0x05; break; case '6' : P2=0x06; break; case '7' : P2=0x07; break; case '8' : P2=0x08; break; case '9' : P2=0x09; break; case 'A' : P2=0x0A; break; case 'B' : P2=0x0B; break; case 'C' : P2=0x0C; break; case 'D' : P2=0x0D; break; case 'E' : P2=0x0E; break; case 'F' : P2=0x0F; break; default : break; } return 0; } }
Sorry for my bad English and bad format of the thread it is my first try.
Thank you for the time you've dedicated.:smile:
Last edited by a moderator: