Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "LCD.h"
- #include <htc.h>
- const char ScreenData[39] = {
- 0x41, //A 0
- 0x42, //B 1
- 0x43, //C 2
- 0x44, //D 3
- 0x45, //E 4
- 0x46, //F 5
- 0x47, //G 6
- 0x48, //H 7
- 0x49, //I 8
- 0x4A, //J 9
- 0x4B, //K 10
- 0x4C, //L 11 //CHARACTER DEFINITIONS!
- 0x4D, //M 12
- 0x4E, //N 13
- 0x4F, //O 14
- 0x50, //P 15
- 0x51, //Q 16
- 0x52, //R 17
- 0x53, //S 18
- 0x54, //T 19
- 0x55, //U 20
- 0x56, //V 21
- 0x57, //W 22
- 0x58, //X 23
- 0x59, //Y 24
- 0x5A, //Z 25
- 0x20, //SPACE 26
- 0x3A, //: 27
- 0x30, //0 28
- 0x31, //1 29
- 0x32, //2 30
- 0x33, //3 31
- 0x34, //4 32
- 0x35, //5 33
- 0x36, //6 34
- 0x37, //7 35
- 0x38, //8 36
- 0x39, //9 37
- 0x25 //% 38
- };
- void Strobe_LCD()
- {
- E=1;
- _delay(4000);
- E=0;
- }
- /**********************************************************/
- void Busy_Flag()
- {
- RW = 1; //read mode
- while(RB7); //Loop until finished
- RW=0; //default to write mode...
- }
- void Write_LCD(unsigned char d,unsigned char x) //USE "Write_LCD(tabledata,1=cap0=lowercase);" (IF number Cap selection must equal 0!)
- {
- char z = 0x00;
- if(!x)
- {
- z=0x20;
- }
- TRISB=0x00;
- PORTB=d+z;
- Strobe_LCD();
- Busy_Flag();
- TRISB=0xFF;
- }
- void AddressDisplay(unsigned char c)
- {
- Busy_Flag(); //check LCD ready
- RW = 0; //write mode
- RS=0; //command mode
- PORTB=c; //place data on data port
- TRISB = 0; //PORTB output
- Strobe_LCD();
- RS=1;
- TRISB = 0xFF; //PORTB input
- }
- void lcd_init()
- {
- Write_LCD(0x38,1);
- Write_LCD(0x0C,1);
- Write_LCD(0x01,1);
- }
Add Comment
Please, Sign In to add comment