#include <18F458.h>
#fuses HS,NOLVP,NOWDT,PUT,NOPROTECT,NOCPD
#use delay(clock=20000000) // defind crystal = 4MHz
#define LCDCLK PIN_C2 // DISPLAY CLOCK
#define LCDLD PIN_C1 // DISPLAY LOAD
#define LCDDIN PIN_C0 // DISPLAY DATA
#define MS 500
/* Dip switch
[000] [0] [00] 10
| | | |
| | | + Default 3 bit Serial
| | + อัตราความเร็ว
| + เน็ตเวอร์ค [0=ไม่มี Address, 1=มี address]
+ Address ของตัว RS485
*/ reset() {
output_low(PIN_B0);
output_low(PIN_B1);
output_low(PIN_B2);
output_low(PIN_B3);
output_low(PIN_B4);
output_low(PIN_B5);
output_low(PIN_B6);
output_low(PIN_B7);
}
void put(char x)
{ // change putchar for TLCD-164
int i;
for (i=0;i<=7;i++)
{
if ((x & 0x80)==0)
output_low(LCDDIN);
else
output_high(LCDDIN);
output_low(LCDCLK);
delay_us(50); // approx 10 uS
output_high(LCDCLK);
x = x << 1;
}
output_low(LCDLD);
delay_us(50);
output_high(LCDLD);
delay_us(550); // approx 100 uS
}
void BackLight_On()
{
printf(put,":9\r");delay_ms(20);
}
void BackLight_Off()
{
printf(put,":A\r");delay_ms(20);
}
void CLRSCR()
{
printf(put,":5\r");delay_ms(300);
}
main()
{
delay_ms(1000);
BackLight_On();
CLRSCR();
printf(put,":5\r"); delay_ms(50);
printf(put,":2 คุณจักรกฤษณ์\r"); delay_ms(100);
printf(put,":2 แสงแก้ว\r"); delay_ms(100);
printf(put,":2 เอ็นโปรเท็ค\r"); delay_ms(100);
printf(put,":2 ประเทศไทย\r"); delay_ms(100);
while(1){
reset();
output_high(PIN_B0);
delay_ms(MS);
reset();
output_high(PIN_B1);
delay_ms(MS);
reset();
output_high(PIN_B2);
delay_ms(MS);
reset();
output_high(PIN_B3);
delay_ms(MS);
reset();
output_high(PIN_B4);
delay_ms(MS);
reset();
output_high(PIN_B5);
delay_ms(MS);
reset();
output_high(PIN_B6);
delay_ms(MS);
reset();
output_high(PIN_B7);
delay_ms(MS);
}
}
|