rishi@india
New Member
how to move cursor to next line
i tried to pass 0xc0 cmd but its not working
i tried to pass 0xc0 cmd but its not working
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.
#include <xc.h> //CONFIG
#include <stdio.h>
#include <stdlib.h>
#include "XLCD.h"
#define _XTAL_FREQ 1000000 // if 8Mhz is HS
#pragma config FOSC = XT // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
unsigned int hienled (void);
unsigned char buffer[20];
unsigned long ADCvalue = 0;
unsigned int voltage;
int x;
void ADCinit (void)// khoi tao adc
{ // chon tan so clock cho bo adc
ADCS2 = ADCS1 = 0;
ADCS0 = 1; // chon kenh adc la kenh an0
CHS2 = CHS1 = CHS0 = 0; // chon cach luu data
ADFM = 1; // cau hinh cong vao
PCFG3 = PCFG2 = PCFG1 = 1;
PCFG0 = 0; // cap nguon cho khoi adc
}
unsigned int hienled (void)// doc led 7 doan
{
ADON = 1;
GO = 1;
delayUs(100);
while(GO);
return (int)ADRESH*256 + ADRESL;
}
void main()
{
TRISA = 0xff;
LCD_PORT = 0;
TRIS_LCD_PORT = 0x00;
TRIS_RW = TRIS_RS = TRIS_E = 0;
ADCinit();
OpenXLCD(0x28);
while(1)
{
ADCvalue = hienled();
voltage = ADCvalue * 5000 / 1023 ;
x = voltage / 10 ;
sprintf(buffer," TEMP = %d%c",x,0xDF);
SetCGRamAddr(0);
putsXLCD(buffer);
OpenXLCD(0xc0);
putsXLCD("Temperature Sensor");
SetCGRamAddr(0);
putsXLCD(buffer);
}
}
while(1)
{
ADCvalue = hienled();
voltage = ADCvalue * 5000 / 1023 ;
x = voltage / 10 ;
sprintf(buffer," TEMP = %d%c",x,0xDF);
SetCGRamAddr(0);
putsXLCD(buffer);
WriteCmdXLCD(0x0);
putsXLCD("Temperature Sensor");
WriteCmdXLCD(0xC0);
putsXLCD(buffer);
}