EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / #include#define

#include#define

|

Projects › Projects › Parallex RFID_PIC16f877a_LCD_Hi Tech C › #include#define

October 6, 2011 at 11:15 am #6681
Jaden Ng
Participant

wysiwyg_imageupload:2839:wysiwyg_imageupload:2840:wysiwyg_imageupload:2842:

#include<htc.h>
#define _XTAL_FREQ 4e6
__CONFIG(0x3F39);
#define RS RC4
#define EN RC5
#define databits PORTB

unsigned char i=0;
unsigned char data[]=”Blind ID No.”;
unsigned char tag_id[12];

void usrt_init()
{
TXEN=1;
SYNC=0;
BRGH=0; // low baud rate
SPBRG=25; //baud rate 2400
TRMT=1;
SPEN=1;
CREN=1;
}

void interrupt_enable()
{
GIE=1;
PEIE=1;
RCIE=1;
}

void interrupt UART() //interrupt service routine
{
 tag_id=RCREG;
 i++;
}

void LCD_STROBE(void)
{
EN = 1;
__delay_us(2);
EN = 0;
}

void lcddata(unsigned char c)
{
RS = 1;
__delay_us(50);
databits = (c >> 4);
LCD_STROBE();
databits = (c);
LCD_STROBE();
}

void cmd(unsigned char c)
{
RS = 0;
__delay_us(50);
databits = (c >> 4);
LCD_STROBE();
databits = (c);
LCD_STROBE();
}

void clear(void)
{
cmd(0x01);
__delay_ms(2);
}

void lcd_init()
{
__delay_ms(15);
cmd(0x28);
__delay_ms(1);
cmd(0x28);
__delay_us(100);
cmd(0x28);
cmd(0x28); // Function set (4-bit interface, 2 lines, 5*7Pixels)
cmd(0x28); // Function set (4-bit interface, 2 lines, 5*7Pixels)
cmd(0x0c); // Make cursorinvisible
clear(); // Clear screen
cmd(0x6); // Set entry Mode(auto increment of cursor)
}

 

void main()
{
TRISB=0;
TRISC4 = 0;
TRISC5 = 0;
usrt_init();
interrupt_enable();
lcd_init();

while(data!=’’)
{
 lcddata(data
);
 i++;
}
while(1)
{
 i=0;
 while(i<12);
 cmd(0xc0);
 i=0;
 while(i<12)
 {
   lcddata(tag_id
);
   i++;
 }

}
}

 

 

this is my code use to detect rfid tag’s code and sdisplay with lcd.this is using hi tech c.

but some weird characters occured.what’s the problem?

i have posted the pics…

 

 

RSS feed: Recent Posts Recent Posts

  • Advice for an ESP32 Soil Tensiometer project with 5V sensors September 9, 2026
  • Marantz SR4500 – CS49400 DSP reverse-engineering / custom active crossover September 9, 2026
  • How does an air tag work? September 9, 2026
  • Cheap ways to link 5 Keithley units and 4 BNC units? September 8, 2026
  • Sony KV-29VL40 - 4 Blink error - IC001 Pin 17 high September 8, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 Arrowfly LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of Arrowfly
Privacy Policy | Advertising

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise