Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
// Lcd pinout settings
sbit LCD_RS at RC6_bit;
sbit LCD_EN at RC7_bit;
sbit LCD_D7 at RC3_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D4 at RC0_bit;
sbit LCD_RS_Direction at TRISC6_bit;
sbit LCD_EN_Direction at TRISC7_bit;
sbit LCD_D4_Direction at TRISC0_bit;
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D6_Direction at TRISC2_bit;
sbit LCD_D7_Direction at TRISC3_bit;
unsigned long ADRead;
unsigned int vDisp[3];
unsigned char Display[7];
void main() {
PORTA = 0;
TRISA = 0X01;
PORTC = 0;
TRISC = 0;
LCD_Init();
LCD_Cmd(_LCD_CURSOR_OFF);
LCD_Cmd(_LCD_CLEAR);
LCD_Out(1, 1, "Temp:");
//Display = "+125 'C";
Display[4] = 39; //'
Display[5]= 'C';
ADCON1 = 0x0E;
ADC_Init();
while (1){
ADRead = (ADC_Get_Sample(0) * 0.4883); //from 500
vDisp[0] = ADRead / 100;
vDisp[1] = (ADRead / 10) % 10;
vDisp[2] = ADRead % 10;
Display[1] = vDisp[0] + 48; // I changed 48 to 70 for checking
Display[2] = vDisp[1] + 48;
Display[3] = vDisp[2] + 48;
LCD_Chr(1, 8, Display[0]);
LCD_Chr(1, 9, Display[1]);
LCD_Chr(1, 10, Display[2]);
LCD_Chr(1, 11, Display[3]);
LCD_Chr(1, 12, Display[4]);
LCD_Chr(1, 13, Display[5]);
//LCD_Out(1, 8, ); // 'Show temperature
delay_ms(200); //200ms delay for waiting
}
}
// Lcd pinout settings
sbit LCD_RS at RC6_bit;
sbit LCD_EN at RC7_bit;
sbit LCD_D7 at RC3_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D4 at RC0_bit;
sbit LCD_RS_Direction at TRISC6_bit;
sbit LCD_EN_Direction at TRISC7_bit;
sbit LCD_D4_Direction at TRISC0_bit;
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D6_Direction at TRISC2_bit;
sbit LCD_D7_Direction at TRISC3_bit;
unsigned long ADRead;
unsigned int vDisp[3];
unsigned char Display[7];
void main() {
PORTA = 0;
TRISA = 0X01;
PORTC = 0;
TRISC = 0;
LCD_Init();
LCD_Cmd(_LCD_CURSOR_OFF);
LCD_Cmd(_LCD_CLEAR);
LCD_Out(1, 1, "Temp:");
//Display = "+125 'C";
Display[4] = 39; //'
Display[5]= 'C';
ADCON1 = 0x0E;
ADC_Init();
while (1){
ADRead = (ADC_Get_Sample(0) * 0.4883);
vDisp[0] = ADRead / 100;
vDisp[1] = (ADRead / 10) % 10;
vDisp[2] = ADRead % 10;
Display[1] = vDisp[0] + 48;
Display[2] = vDisp[1] + 48;
Display[3] = vDisp[2] + 48;
LCD_Chr(1, 8, Display[0]);
LCD_Chr(1, 9, Display[1]);
LCD_Chr(1, 10, Display[2]);
LCD_Chr(1, 11, Display[3]);
LCD_Chr(1, 12, Display[4]);
LCD_Chr(1, 13, Display[5]);
//LCD_Out(1, 8, ); // 'Show temperature
delay_ms(200); //200ms delay for waiting
}
}
...on breadboard only Lcd back light on and black squares appear but output does not shows...
Connect pull up resisters on pins that connected to lcd.
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 // Lcd pinout settings sbit LCD_RS at RC6_bit; sbit LCD_EN at RC7_bit; sbit LCD_D7 at RC3_bit; sbit LCD_D6 at RC2_bit; sbit LCD_D5 at RC1_bit; sbit LCD_D4 at RC0_bit; sbit LCD_RS_Direction at TRISC6_bit; sbit LCD_EN_Direction at TRISC7_bit; sbit LCD_D4_Direction at TRISC0_bit; sbit LCD_D5_Direction at TRISC1_bit; sbit LCD_D6_Direction at TRISC2_bit; sbit LCD_D7_Direction at TRISC3_bit; float ADRead, oldVal = 0.0; unsigned char display[23]; const char character[] = {6,9,9,6,0,0,0,0}; void CustomChar(char pos_row, char pos_char) { char i; Lcd_Cmd(64); for (i = 0; i<=7; i++) Lcd_Chr_CP(character[i]); Lcd_Cmd(_LCD_RETURN_HOME); Lcd_Chr(pos_row, pos_char, 0); } void main() { TRISA = 0x01; PORTA = 0x00; TRISC = 0x80; PORTC = 0x00; ADCON1 = 0x0E; LCD_Init(); LCD_Cmd(_LCD_CURSOR_OFF); LCD_Cmd(_LCD_CLEAR); LCD_Out(1, 1, "Temp: "); UART1_Init(9600); Delay_ms(200); while (1){ ADRead = ADC_Read(0) * 0.4883; if(oldVal != ADRead) { FloatToStr(ADRead, display); display[8] = '\0'; LCD_Out(1, 7, display); CustomChar(1, 15); LCD_Out(1, 7, "C"); strcat(display, "\r\n"); UART1_Write_Text(display); oldVal = ADRead; } Delay_ms(200); } }