Wednesday, December 26, 2018
T10
\
void main()
{
unsigned char Dec,d1,d2,d3;
unsigned char Bin[8];
unsigned char keypad[]={0,1,2,3,0,
4,5,6,0,
7,8,9,0,
0,0,0,0};
unsigned int kp,i;
TRISC=0;
TRISD=0xFF;
Lcd_Init(&PORTC);
Keypad_Init(&PORTD);
Lcd_Cmd(LCD_CURSOR_OFF);
Return:Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Dec>Bin Bin>Dec");
Lcd_Out(2,1," 1 2 ");
while(Keypad_Read()!=1&&Keypad_Read()!=2);
if(Keypad_Read()==1)goto DectoBin;
if(Keypad_Read()==2)goto BintoDec;
DectoBin:while(Keypad_Read());
Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Enter Dec");
for(i=0;i<2;i++)
{
while(!Keypad_Read());
kp=Keypad_Read();
Dec=Dec*10*i+keypad[kp];
Lcd_Chr(2,i+1,keypad[kp]+48);
while(Keypad_Read());
}
Bin[0]=Dec%2;
Bin[1]=(Dec/2)%2;
Bin[2]=(Dec/4)%2;
Bin[3]=(Dec/8)%2;
Bin[4]=(Dec/16)%2;
Bin[5]=(Dec/32)%2;
Bin[6]=(Dec/64)%2;
Bin[7]=(Dec/128)%2;
while(Keypad_Read()!=15);
Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Bin");
for(i=0;i<8;i++)
{
Lcd_Chr(2,i+1,Bin[7-i]+48);
}
while(Keypad_Read());
while(Keypad_Read()!=15);
goto Return;
BintoDec:while(Keypad_Read());
Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Enter Bin");
for(i=0;i<8;i++)
{
while(Keypad_Read()!=1&&Keypad_Read()!=14);
kp=Keypad_Read();
Bin[7-i]=keypad[kp];
Lcd_Chr(2,i+1,Bin[7-i]+48);
while(Keypad_Read());
}
Dec=Bin[0];
Dec=Dec+Bin[1]*2;
Dec=Dec+Bin[2]*4;
Dec=Dec+Bin[3]*8;
Dec=Dec+Bin[4]*16;
Dec=Dec+Bin[5]*32;
Dec=Dec+Bin[6]*64;
Dec=Dec+Bin[7]*128;
d1=Dec/100;
d2=(Dec%100)/10;
d3=Dec%10;
while(Keypad_Read()!=15);
Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Dec");
Lcd_Chr(2,1,d1+48);
Lcd_Chr(2,2,d2+48);
Lcd_Chr(2,3,d3+48);
while(Keypad_Read());
while(Keypad_Read()!=15);
goto Return;
}
Subscribe to:
Post Comments (Atom)
สรุปงานที่ 5 Internet of Things (IoT)
Internet of Things (IoT) คืออะไร Internet of Things (IoT) คือ "อินเตอร์เน็ตในทุกสิ่ง" หมายถึง การที่อุปกรณ์ต่างๆ ส...
-
Digital Speedometer and Odometer Circuit using PIC Microcontroller EMBEDDED By Aswinth Raj Jul 27, 2017 24 Digital Speedometer and...
-
How to Save Data using EEPROM in PIC16F877A Microcontroller By Aswinth Raj Aug 10, 2017 2 Saving Data using...
-
Generating PWM using PIC Microcontroller with MPLAB and XC8 EMBEDDED By Aswinth Raj Mar 15, 2017 35 Generating PWM using PIC Micr...
No comments:
Post a Comment