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 / try this

try this

|

Microcontroller › AVR › LCD JHD 162a not displaying Characters › try this

January 19, 2013 at 4:21 am #8980
nidhin.k
Participant

try this code…..

 

 

 

#include<avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
#include <util/delay.h>
 
#define First_Line 0x80
#define Second_Line 0xc0
#define Curser_On  0x0f
#define Curser_Off 0x0c
#define Clear_Display 0x01
 
#define Data_Port PORTD
 
#define enable  PORTC |= 0x80
#define disable PORTC &= ~0x80
 
#define data_mode PORTC |= 0x40
#define cmd_mode  PORTC &= ~0x40
 
void Lcd4_Init();
void Lcd4_Command(unsigned char);
void Lcd4_Write(unsigned char,unsigned char);
void Lcd4_Display(unsigned char,const unsigned char*,unsigned int);
void Delay(unsigned int);
 
 
unsigned char Lcd_com1,Lcd_com2,Lcd_Temp;
 
 
 
void main()
{
cli();
DDRC=0xff;
DDRD=0xff;
sei();
Lcd4_Init();
while(1)
{
Lcd4_Display(0x80,”welcome to atmga”,16);
Lcd4_Display(0xc0,”welcome to atmga”,16);
}
}
 
void Lcd4_Init()
{
Lcd4_Command(0x38);
 
Lcd4_Command(0x02); //return home
 
Lcd4_Command(0x28); //to select function set
 
Lcd4_Command(0x06); //entry mode set
 
Lcd4_Command(0x0c); //display on
 
Lcd4_Command(0x01); //clear display
}
 
void Lcd4_Display(unsigned char com,const unsigned char *word,unsigned int n)
{
unsigned char Lcd_i;
for(Lcd_i=0;Lcd_i<n;Lcd_i++)
{ 
Lcd4_Write(com+Lcd_i,word[Lcd_i]);
  }
}
 
void Lcd4_Command(unsigned char com)
{
Lcd_com1 = com & 0xf0;
Lcd_com2 = com & 0x0f;
Lcd_com2 = Lcd_com2<<4;
 
// disable;
          //sel command reg
Lcd_Temp = Data_Port & 0x0f;        
Data_Port=Lcd_Temp | Lcd_com1; 
cmd_mode;           //send com to po
enable;             //clock
_delay_ms(5);
disable;
_delay_ms(5);
Lcd_Temp = Data_Port & 0x0f;        
Data_Port=Lcd_Temp | Lcd_com2;
cmd_mode;           //send com to po
enable;             //clock
_delay_ms(5);
disable;
_delay_ms(5);
}
 
void Lcd4_Write(unsigned char com,unsigned char dat)
{
Lcd4_Command(com);
_delay_ms(5);
Lcd_com1 = dat & 0xf0;
Lcd_com2 = dat & 0x0f;
Lcd_com2 = Lcd_com2<<4;
 
// disable;
        //sel data reg
Lcd_Temp = Data_Port & 0x0f;        
Data_Port=Lcd_Temp | Lcd_com1;  
data_mode;         //send com to po
enable;             //clock
_delay_ms(5);
disable; 
_delay_ms(5);       //sel data reg
Lcd_Temp = Data_Port & 0x0f;        
Data_Port=Lcd_Temp | Lcd_com2; 
data_mode;         //send com to po
enable;             //clock
_delay_ms(5);
disable;
cmd_mode; 
_delay_ms(5);
}
 
void Delay(unsigned int del)
{
while(del–);
}     
 

RSS Recent Posts

  • PCB manufacturing issues April 18, 2026
  • Bot checks April 18, 2026
  • Convenient audio FFT module? April 18, 2026
  • SDCC Array Access In Timer 0 Interrupt Handler April 18, 2026
  • Assistance locating a 'trail' camera gadget, please ? April 18, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media 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 WTWH Media
Privacy Policy | Advertising | About Us

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