void Welcome(unsigned char c[],unsigned char d[]) { unsigned int i=0; lcdcmd(0x01); DelayMs(10); lcdcmd(0x80); DelayMs(10); i=0; while(c[i]!='\0') { lcdData(c[i]); i++; } lcdcmd(0xc0); DelayMs(10); i=0; while(d[i]!='\0') { lcdData(d[i]); i++; } }
void lcdInit(void) { //Port config lcd_port_dir_conf(); waitlcd(500); lcdRSOff(); lcdENOff(); lcdPortDataOut(0x03); waitlcd(40); lcdENOn(); lcdENOff(); waitlcd(5); lcdENOn(); lcdENOff(); waitlcd(5); lcdENOn(); lcdENOff(); waitlcd(2); lcdPortDataOut(0x02); lcdENOn(); lcdENOff(); lcdcmd(0x28); //set data length 4 bit 2 line waitlcd(250); lcdcmd(0x0E); // set display on cursor on blink on waitlcd(250); lcdcmd(0x01); // clear lcd waitlcd(250); lcdcmd(0x06); // cursor shift direction waitlcd(250); lcdcmd(0x80); //set ram address waitlcd(250); }
void temps() //Function to display temp change { int j; j=0; menudisplay(); lcdcmd(0xC0); while(str3[j]!='\0') { lcddata(str3[j]); j++; } delay(10000000); while(PORTDbits.RD13==1&&PORTDbits.RD7==1&&PORTDbits.RD6==1); //Wait till any key press if(PORTDbits.RD7==0) { i++; lcdcmd(0x01); } else if(PORTDbits.RD13==0) { settemp(); delay(100000000); } else if(PORTDbits.RD6==0) { i--; lcdcmd(0x01); } }
void prints(const rom char * message){ // Write message to LCD (C string type) lcdcmd(0x8); // disable display; while (*message){ // Look for end of string lcdData(*message++); } lcdcmd(0xE); // enable display; }
void lcdinit(void) { RS=0; EN=0; PORTC= 0x3; waitlcd(40); EN=1; EN=0; waitlcd(5); EN=1; EN=0; waitlcd(5); EN=1; EN=0; waitlcd(2); PORTC=2; EN=1; EN=0; lcdcmd(0x28); //set data length 4 bit 2 line waitlcd(250); lcdcmd(0x0E); // set display on cursor on blink on waitlcd(250); lcdcmd(0x01); // clear lcd waitlcd(250); lcdcmd(0x06); // cursor shift direction waitlcd(250); lcdcmd(0x80); //set ram address waitlcd(250); }
void welcome(void) { unsigned int i=0; unsigned char c[]="WELCOME TO RFID"; unsigned char d[]="SECURITY SYSTEM"; lcdcmd(0x01); DelayMs(10); lcdcmd(0x80); DelayMs(10); while(c[i]!='\0') { lcdData(c[i]); i++; } lcdcmd(0xc0); i=0; while(d[i]!='\0') { lcdData(d[i]); i++; } }
void ConvertAndDisplay(unsigned int value1,unsigned char c[]) { unsigned int i,a=0,j; unsigned char d1,d2,d3; for(i=0;i<value1;i++) a=a+1; lcdcmd(0x01); DelayMs(10); lcdcmd(0x80); DelayMs(10); j=0; while(c[j]!='\0') { lcdData(c[j]); j++; } d1=a%10; //digits before desible point a=a/10; d2=a%10; a=a/10; d3=a%10; lcdcmd(0xc0); DelayMs(10); display(d1,d2,d3); }
void manualmode() { menudisplay(); int j=0; lcdcmd(0xC0); while(str6[j]!='\0') { lcddata(str6[j]); j++; } while(PORTDbits.RD6==1&&PORTDbits.RD13==1); if(PORTDbits.RD13==0) { PORTA=0xff; delay(1000000); PORTA=0x00; } else if(PORTDbits.RD6==0) { lcdcmd(0x01); } delay(1000000000); }
//lcd initialisation---------------------------------------------------- void lcdinit() { en=0; delay(25); lcdcmd(0x38); lcdready(); //delay(20); lcdcmd(0x0E); lcdready(); //delay(20); lcdcmd(0x06); //delay(20); lcdready(); lcdcmd(0x01); delay(20); lcdcmd(0x02); delay(20); }
void lcdinit(void) { lcdcmd(0x38); //2 lines and 5X7 matrix lcdcmd(0x0C); //Display ON, Cursor Blinking = 0x0E But this command is Display ON, Cursor OFF lcdcmd(0x01); //Clear Display Screen lcdcmd(0x80); //Force Cursor to the beginning of the First Line lcdcmd(0x06); }
void dis_cmd(char cmd_value) { char cmd_value1; cmd_value1 = cmd_value & 0xF0; //mask lower nibble because PA4-PA7 pins are used. lcdcmd(cmd_value1); // send to LCD _delay_ms(10); cmd_value1 = ((cmd_value<<4) & 0xF0); //shift 4-bit and mask lcdcmd(cmd_value1); // send to LCD }
void initialize (void) { lcdcmd (0x30); //1 line and 5x7 matrix delay(1); lcdcmd (0x38); //2 line and 5x7 matrix delay(1); lcdcmd (0x0C); //Display on, cursor off delay(1); lcdcmd (0x01); //Clear display Screen delay(1); lcdcmd (0x06); //shift cursor to right delay(1); }
//--------------------------------------- // Lcd initialization subroutine //--------------------------------------- void lcdinit(void) { lcdcmd(0x38); DelayMs(250); lcdcmd(0x0E); DelayMs(250); lcdcmd(0x01); DelayMs(250); lcdcmd(0x06); DelayMs(250); lcdcmd(0x80); DelayMs(250); }
void lcdini() { mPORTESetPinsDigitalOut(BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); PORTSetPinsDigitalOut(IOPORT_D,BIT_5 | BIT_4); lcdcmd(0x38); msdelay(10); lcdcmd(0x0E); msdelay(10); lcdcmd(0x01); msdelay(10); lcdcmd(0x06); msdelay(10); lcdcmd(0x80); return; }
int main() { i=0; lcdini(); DDPCON=0x0000; mPORTDSetPinsDigitalIn(BIT_7|BIT_13|BIT_6); //Set Portd pins DigitalIn mPORTASetPinsDigitalOut(BIT_0|BIT_1|BIT_2|BIT_3|BIT_4|BIT_5|BIT_6); mPORTAClearBits(BIT_0|BIT_1|BIT_2|BIT_3|BIT_4|BIT_5|BIT_6); mPORTASetPinsDigitalIn(BIT_7); char x; while(1) { switch(i) //Switch case to select function { case 0: mode(); break; case 1: batteryv(); break; case 2: temps(); break; } if(i==3) { lcdcmd(0x01); break; } } }
void automode() { menudisplay(); int j=0; lcdcmd(0xC0); while(str5[j]!='\0') { lcddata(str5[j]); j++; } while(PORTDbits.RD13==1&&PORTDbits.RD7==1); if(PORTDbits.RD13==0) { PORTA=0xff; delay(1000000); } else if(PORTDbits.RD7==0) { manualmode(); } /* while(PORTDbits.RD6==1); if(PORTDbits.RD6==0) { i++; lcdcmd(0x01); }*/ }
void sucessRx() { unsigned int i=0; unsigned char c[]="ACCESS GRANTED"; lcdcmd(0x01); DelayMs(10); lcdcmd(0x80); DelayMs(10); while(c[i]!='\0') { lcdData(c[i]); i++; } }
void unknown(void) { unsigned int i=0; unsigned char c[]="ACCESS DENIED"; lcdcmd(0x01); DelayMs(10); lcdcmd(0x80); DelayMs(10); while(c[i]!='\0') { lcdData(c[i]); i++; } }
void gotoXy(unsigned char x,unsigned char y) { if(x<40) { if(y) x|=0b01000000; x|=0b10000000; lcdcmd(x); } }
void gotoXy(unsigned char x, unsigned char y) { if(x<40) { if(y) // if not zero x |= 0x40; // shift to 1st line (see page 19) x |=0x80; // shift to left start position lcdcmd(x); } }
void gotoXy(unsigned char x,unsigned char y) { if(x<40) { if(y) x |= 0x40; x |=0x80; lcdcmd(x); } }
void display_lcd (unsigned char location, unsigned char *d) { lcdcmd(0x80 | location); delay(1); while(*d) { lcddat(*d++); } }
void main(void) { unsigned int HI, LO, TOTAL; unsigned char l, OV, OFR[16] = "Out Of Range..."; OV = 0; T0 = 1; TMOD = 0x05; TL0 = 0; TL1 = 0; lcdinit(); while(1) { do { start: TR0 = 1; MSDelay(145); LO = TL0; HI = TH0; HI = HI << 8; TOTAL = HI | LO; Unit[0] = 'H'; Unit[1] = 'z'; Unit[2] = ' '; Unit[3] = ' '; if(OV == 1) { TOTAL = TOTAL / 1000; TOTAL = TOTAL + 65; if(TOTAL > 125) { for(l=0; l<16; l++) lcddata(OFR[l]); for(l=0; l<16; l++) lcdcmd(0x10); goto start; } OV = 0; Unit[0] = 'K'; Unit[1] = 'H'; Unit[2] = 'z'; Unit[3] = ' '; } inttoLCD(TOTAL); TL0 = 0; TH0 = 0; } while(TF0 == 0); OV = 1; TR0 = 0; TF0 = 0; } }
void lcdinit(void) { P6OUT &= ~RS; // RS=0 to send cmd P6OUT &= ~EN; // EN=0 to disable P6OUT |= 0x3; // Wakeup (0x30) // waitlcd(40); // wait for 30ms // 4-bits initialisation sequences P6OUT |=EN; // enable P6OUT &=~EN; // disable // waitlcd(5); // P6OUT |=EN; // enable P6OUT &=~EN; // disable // waitlcd(5); // P6OUT |=EN; // enable P6OUT &=~EN; // disable // waitlcd(2); // P6OUT &= 0xF2; // clear (0x02) - Return Home (see page 18) P6OUT |=EN; P6OUT &=~EN; lcdcmd(0x28); // set data length 4 bit 2 line 5x8 dot (see page 19/20) // waitlcd(250); lcdcmd(0x0C); // set Display On; Cursor On; Blink On (see page 19) // waitlcd(250); lcdcmd(0x01); // Clear display (see page 18) // waitlcd(250); lcdcmd(0x06); // Entry mode set - cursor shift direction to right (see page 18) // waitlcd(250); lcdcmd(0x80); //set DDRAM address (see page 20) // waitlcd(250); __delay_cycles(10000); }
void settemp() { int j,b,x,v; j=0; lcdcmd(0x01); lcdcmd(0x80); while(str7[j]!='\0') { lcddata(str7[j]); j++; } x = keypad(); lcdcmd(0xC0); lcddata(x+48); delay(1000000000); v = keypad(); lcdcmd(0xC1); lcddata(v+48); PORTA=0xff; }
void mode() //Function for mode selection { int j; j=0; menudisplay(); lcdcmd(0xC0); while(str1[j]!='\0') { lcddata(str1[j]); j++; } delay(10000000); while(PORTDbits.RD13==1&&PORTDbits.RD7==1); //Wait till any key press if(PORTDbits.RD7==0) { i++; lcdcmd(0x01); } else if(PORTDbits.RD13==0) { mode2(); } }
void batteryv() //Function to display battery voltage { int j; j=0; menudisplay(); lcdcmd(0xC0); while(str2[j]!='\0') { lcddata(str2[j]); j++; } delay(10000000); while(PORTDbits.RD13==1&&PORTDbits.RD7==1&&PORTDbits.RD6==1); //Wait till any key press if(PORTDbits.RD7==0) { i++; lcdcmd(0x01); } else if(PORTDbits.RD13==0) { PORTA=0xff; delay(1000000); PORTA=0x00; while(PORTDbits.RD6==1); if(PORTDbits.RD6==0) { lcdcmd(0x01); } } else if(PORTDbits.RD6==0) { i--; lcdcmd(0x01); } }
void clearLcd(void) { // Send command to LCD (0x01) lcdcmd(0x01); }
// Main routine void main(void) { OSCCON = 0x7C; // Internal Oscillator 16MHz Enabled OSCTUNE = 0x5F; OSCCON2bits.PLLRDY = 1; VREFCON1 = 0xE0; T2CON = 0x7B; INTCONbits.GIE = 1; // Global, peripheral & timer 2 interrupt enable INTCONbits.PEIE = 1; PIE1bits.TMR2IE = 1; PR2 = 0xff; // period registor 2 with max value VREFCON2 = 0; // zero brightness LED_DIR = 0; // LED pin on output LED = 1; lcdinit(); // Initialize LCD in 4bit mode, ultrasonic and brightness lcdcmd(0x01); initUltrasonic(); initBrightness(); LED = 0; while(1) { readPIR(); if(resPIR) { pirIndicate(); readUltrasonic(); f1 = 0; f2 = 1; while(resUS < 100 && resUS > 10) { T2CONbits.TMR2ON = 1; setBrightness(); if(f2) { lcdcmd(0x80); sprintf(line1," Welcome ! "); lcdstring(line1); sprintf(line2," Chaitanya. "); lcdcmd(0xc0); lcdstring(line2); msDelay(1000); f2 = 0; } if(sec >= 60) { mn++; sec = 0; } if(mn >= 60) { hr++; mn = 0; } sprintf(line1," Study Time "); sprintf(line2," %i:%i:%i ",hr,mn,sec); lcdcmd(0x80); lcdstring(line1); lcdcmd(0xc0); lcdstring(line2); eventL(); eventL(); readUltrasonic(); f1 = 1; } T2CONbits.TMR2ON = 0; if(f1) { sprintf(line1," Thank You ! "); sprintf(line2," Good Bye...! "); lcdcmd(0x80); lcdstring(line1); lcdcmd(0xc0); lcdstring(line2); msDelay(3000); VREFCON2 = 0; } lcdcmd(0x01); } } }
void main() { float Frequency, Percent, LowTime, HighTime, TotalDelayMilli, TotalDelayMicro; unsigned int ConvHH, ConvLH, ValueH, ConvHL, ConvLL, ValueL; unsigned char x, HighH, LowH, HighL, LowL; unsigned char Freq[17] = "Freq: Hz", DutyC[17] = "Duty Cycle: %"; unsigned char colloc; Status = 0; KEYPAD = 0xF0; // make higher bits of keypad port that is column bits input and low row bits outputs Clock = 0; lcdcmd(0x38); // 2 lines and 5X7 matrix lcdcmd(0x0C); // Display ON, Cursor Blinking = 0x0E But this command is Display ON, Cursor OFF lcdcmd(0x01); // Clear Display Screen lcdcmd(0x80); // Force Cursor to the beginning of the First Line lcdcmd(0x06); main:lcdcmd(0x01); for(x = 0; x<16; x++) lcddata(Freq[x]); lcdcmd(0xC0); for(x = 0; x<16; x++) lcddata(DutyC[x]); lcdcmd(0x80); for(x=0; x<6; x++) lcdcmd(0x16); lcdcmd(0x0E); Frequency = GetInput(); if(Frequency > 20000) goto main; lcdcmd(0x0C); lcdcmd(0xC0); for(x = 0; x<12; x++) lcdcmd(0x16); lcdcmd(0x0E); Percent = GetInput(); lcdcmd(0x0C); TotalDelayMilli = (1 / Frequency) * 1000; TotalDelayMicro = (TotalDelayMilli * 1000) - 45; //With correction of 45 HighTime = (TotalDelayMicro / 100) * Percent; LowTime = TotalDelayMicro - HighTime; ValueH = 65536 - HighTime; ConvLH = ValueH & 0x00FF; // Zeroing the Higher 8 bits to have Lower 8 bits LowH = ConvLH; // Storing in a 8 bit character ConvHH = ValueH & 0xFF00; // Masking the Lower 8 bits to have Higher 8 bits ConvHH = ConvHH >> 8; // Shifting right 8 bits to hit to the Lower Part to save it to a 8-bit character HighH = ConvHH; // Storing in a 8 bit character ValueL = 65536 - LowTime; ConvLL = ValueL & 0x00FF; // Zeroing the Higher 8 bits to have Lower 8 bits LowL = ConvLL; // Storing in a 8 bit character ConvHL = ValueL & 0xFF00; // Masking the Lower 8 bits to have Higher 8 bits ConvHL = ConvHL >> 8; // Shifting right 8 bits to hit to the Lower Part to save it to a 8-bit character HighL = ConvHL; Status = 1; while(1) //2 Machine Cycle { Clock = 1; //1 MC TimerH(HighH, LowH); Clock = 0; TimerL(HighL, LowL); colloc = KEYPAD; //2 MC colloc &= 0xF0; //2 MC if(colloc == 0xE0) //4 MC { MSDelay(5); colloc = KEYPAD; //read the columns colloc &= 0xF0; //mask unused bits if(colloc == 0xE0) { Status = 0; goto main; } } } } //main braces