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.
/*
* File: main.c
* Author: Selcuk
*
* Created on 02 Kas?m 2012 Cuma, 08:42
*/
#include "main.h"
void Menu(int menuID);
int main() {
TRISB=0;
TRISBbits.TRISB2=0;
LCD_TRIS = 0x00;
TRISB=0;
Delay150MS();
TRISA=0;
LATA=0;
LCD_init();
LCD_goto(2,5);
LCD_char('T');
while(1){
LED=1;
Delay5MS();
LED=0;
Delay5MS();
}
}
#include "lcd.h"
void LCD_init()
{
LCD_cmd(0x20); // 4 bit
LCD_cmd(0x28); // display shift
LCD_cmd(0x6); // character mode
LCD_cmd(0xc); // display on / off and cursor
LCD_clr(); // clear display
}
void LCD_goto(char line, char column) // combines line and lineW
{
unsigned char data = 0x80; // default to 1
if(line == 2)data = 0xc0; // change to 2
data += column; // add in column
LCD_cmd(data);
}
void LCD_clr()
{
LCD_cmd(1); // Clr screen
}
void LCD_cur(char on)
{
unsigned char cur = 0xc; // cursor off
if(on) cur = 0xd; // cursor on
LCD_cmd(cur);
}
void LCD_cmd(unsigned char ch)
{
LCD_PORT = ch & 0xf0; // write high nibble
LCD_RS = 0;
pulse_E();
LCD_PORT = ch <<4 & 0xf0; // write low nibble
LCD_RS = 0;
pulse_E();
Delay5MS();
}
void LCD_char(unsigned char ch)
{
LCD_PORT = ch & 0xf0; // write high nibble
LCD_RS = 1;
pulse_E();
LCD_PORT = ch <<4 & 0xf0; // write low nibble
LCD_RS = 1;
pulse_E();
Delay5MS();
}
void LCD_charD(unsigned char ch)
{
ch+=0x30;
LCD_char(ch); // convert to ascii
}
void pulse_E()
{
LCD_E = 1;
Delay1US();
LCD_E = 0;
}
void string(const char *q,const int satir)
{
int sayac=0;
while (*q) {
LCD_goto(satir,sayac);
LCD_char(*q++);
sayac++;
}
}
void LCDinit(char c)
{
PORTB = 0;
TRISB = 0x3;
PORTB = 0x30;
PORTB += 4;
PORTB -= 4;
Delay10KTCYx(22);
PORTB += 4;
PORTB -= 4;
Delay10KTCYx(22);
LCDcmd(0x32);
Delay10KTCYx(22);
LCDcmd(0x2C);
Delay10KTCYx(28);
LCDcmd(0x6);
Delay10KTCYx(28);
LCDcmd(0xC);
Delay10KTCYx(10);
LCDcmd(c);
Delay1KTCYx(1);
}