void main() { int i=0; char str[20]; char a; /*------------------------------------------------ Setup the serial port for 2400 baud at 11.0592MHz. ------------------------------------------------*/ SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 0xFD; /* TH1: reload value for 2400 baud @ 11.0592MHz */ TR1 = 1; /* TR1: timer 1 run */ TI = 1; /* TI: set TI to send first char of UART */ Lcd8_init(); relay =0; while(1) { scanf("%c",&a); Lcd8_Set_Cursor(1,i++); Lcd8_Write_Char(a); if(a == 'a') { relay =1; Delay(1000); } else if(a == 'b') { relay =0; Delay(1000); } if(i==16) { Lcd8_Clear(); i=0; } } }
void main(void) { init_DigIO(); init_timer(); Lcd8_Init(); init_SWTimer(); // Enable peripherial interrupts and start processing PEIE = 1; // Enable peripheral interrupt GIE = 1; // Enable global interrupt Start_Timer(TIMER_0,10); //unsigned char tempcounter; //Switch Off alarm and heater; //Input_Time =Read_switch(); //Lcd8_Set_Cursor(LCD_LINE_1,0); //Lcd8_Write_String("Voltage ->"); Lcd8_Set_Cursor(LCD_LINE_1,0); Lcd8_Write_String("Voltage:"); Lcd8_Set_Cursor(LCD_LINE_2,0); Lcd8_Write_String("Current:"); //PORTC=0x80; //TRISB=0x00; while (1) { //Lcd8_Set_Cursor(LCD_LINE_2,1); //Lcd8_Write_Char(Time_Sec); //PORTB++; //PORTC ^=0x80; if (GetTimer_State(TIMER_0 ==TIMER_EXPIRED)) { //Display AN2 Lcd8_Set_Cursor(LCD_LINE_1,9); adc_result_an2 = Read_Adc(ADC_AN3); if(adc_result_an2 >10) { Lcd8_Write_Char('+'); } else { Lcd8_Write_Char('-'); adc_result_an2 = Read_Adc(ADC_AN2); } adc_result_an2>>=1; temp1=adc_result_an2/100; //Lcd8_Set_Cursor(LCD_LINE_1,10); Lcd8_Write_Char(temp1 | 0x30); temp1=adc_result_an2/10; temp1= temp1%10; //Lcd8_Set_Cursor(LCD_LINE_2,11); Lcd8_Write_Char(temp1 | 0x30); Lcd8_Write_Char('.'); temp1= adc_result_an2%10; //Lcd8_Set_Cursor(LCD_LINE_2,12); Lcd8_Write_Char(temp1 | 0x30); Lcd8_Write_Char('V'); //00000000000000000000000000000000000000000000000 // 4-20 ma adc_result_an2 = Read_Adc(ADC_AN4); #if 0 if(adc_result_an2 >2) { adc_result_an2-=2; } adc_result_an2<<=2; #endif //adc_result_an2<<=2; temp1=adc_result_an2/100; Lcd8_Set_Cursor(LCD_LINE_2,10); Lcd8_Write_Char(temp1 | 0x30); temp1=adc_result_an2/10; temp1= temp1%10; //Lcd8_Set_Cursor(LCD_LINE_2,11); Lcd8_Write_Char(temp1 | 0x30); Lcd8_Write_Char('.'); temp1= adc_result_an2%10; //Lcd8_Set_Cursor(LCD_LINE_2,12); Lcd8_Write_Char(temp1 | 0x30); Lcd8_Write_Char('m'); Lcd8_Write_Char('A'); //------------------------------------------------------------------ Start_Timer(TIMER_0,2000); // Call every 1000ms cyclic timer //---------------------------------------------------------------------------------------- } // While ends }
void main() { int l; Relay = 0; Buz = 1; TMOD=0x20; //Enable Timer 1 TH1=0XFD; SCON=0x50; TR1=1; Lcd8_init(); Lcd8_Set_Cursor(1,1); Lcd8_Write_String("Welcome to RFID "); Delay(1000); Lcd8_Set_Cursor(2,1); Lcd8_Write_String("Security System"); Lcd8_Set_Cursor(1,1); Delay(1000); Lcd8_Clear(); Lcd8_Write_String("PLZ Show Your RFID "); Delay(1000); Lcd8_Set_Cursor(2,1); Lcd8_Write_String("Card"); while(1) { recieve(); if(card_id[7] == 'N' && card_id[8] == 'J' && card_id[9] == 'J' && card_id[10] == 'N' && card_id[11] == '0') { Lcd8_Clear(); Lcd8_Set_Cursor(1,1); Lcd8_Write_String("ACCESS GRANTED "); Relay = 1; Delay(300); Relay = 0; Delay(300); OPENM = 0; Delay(600); OPENM = 1; Delay(300); CLOSEM = 0; Delay(600); CLOSEM = 1; Lcd8_Set_Cursor(2,1); for(l=7;l<12;l++) { Lcd8_Write_Char(card_id[l]); } } else { Lcd8_Clear(); Lcd8_Set_Cursor(1,1); Lcd8_Write_String("ACCESS DENIED "); Relay = 0; Delay(100); Buz = 0; Delay(5000); Buz = 1; Delay(200); Lcd8_Set_Cursor(2,1); for(l=7;l<12;l++) { Lcd8_Write_Char(card_id[l]); } } Delay(2000); Lcd8_Clear(); Lcd8_Write_String("PLZ Show Your RFID "); Delay(1000); Lcd8_Set_Cursor(2,1); Lcd8_Write_String("Card"); } }