Microcontroller › AVR › Temperature display on LCD › sorry for misconceptions you
sorry for misconceptions you just need to do +48 in the values here i am sending the complete i my self compiled and checked it….
/*
LCD data transfer through 8 bit mode
jsut writing a single letter 137 on LCD
LCD DATA port—-PORT A
signal port
PORT B
rs
PB0
rw
PB1
en
PB2
usidng internal clock frequency 1MHz
*/
#include
#include
#define LCD_DATA PORTA //LCD data port
#define signal PORTB
#define en PB2 //enable signal
#define rw PB1 //read/write signal
#define rs PB0 //resister select signal
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
void character();
int main()
{
DDRA=0xff; //making LCD_DATA port as out put port
DDRB=0x07; //making signal as out put
init_LCD(); //initialization of LCD
_delay_ms(50); // delay of 50 mili seconds
LCD_cmd(0xC0); // —8 go to first line and –0 is for 0th position
_delay_ms(1);
unsigned char value_t=137,i,j;
unsigned char ar[4];
for(i=0;value_t>=10;i++)
{
ar=(value_t)%10;
(value_t)=(value_t)/10;
}
LCD_write(value_t+48);
for(j=2;j>0 ;j–)
{
LCD_write(ar[j-1]+48);
}
_delay_ms(100);
}
void init_LCD(void)
{
LCD_cmd(0x38); //initializtion of 16X2 LCD in 8bit mode
_delay_ms(1);
LCD_cmd(0x01); //clear LCD
_delay_ms(1);
LCD_cmd(0x0E); //cursor ON
_delay_ms(1);
LCD_cmd(0x80); // —8 go to first line and –0 is for 0th position
_delay_ms(1);
return;
}
void LCD_cmd(unsigned char cmd)
{
LCD_DATA=cmd;
signal =(0<
signal =(0<
return;
}
void LCD_write(unsigned char data)
{
LCD_DATA= data;
signal = (1<
signal = (1<
return ;
}