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
You are here: Home / Replies / i wana display msg on lcd

i wana display msg on lcd

|

Microcontroller › AVR › 4 bit LCD interfacing with ATmega32 › i wana display msg on lcd

August 13, 2012 at 11:44 am #8449
a
Participant

i wana display msg on lcd interfaced with atmega 32. i want to use PB.0-rs, PB.1-rw, PB.2- en , and want to use data pins of same port i.e PB.4 TO PB.7. Here is my code…..cn ny 1 help me to solv out the prblm. wn i burn this code nthing is display on lcd.

 

 

//Program to Display string on LCD using AVR Microcontroller (ATmega16)
/*
LCD DATA port—-PORT B
signal port


PORT D
    rs


PD0
    rw


PD1
    en


PD2
*/
 
#include<mega32.h>
#include<delay.h>
 
#define LCD_DATA PORTB        //LCD data port
 
#define ctrl PORTB
#define en PORTB2        // enable signal
#define rw PORTB1        // read/write signal
#define rs PORTB0        // register select signal
 
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
void LCD_write_string(unsigned char *str) ;
 
 
void  main()
{
    DDRB=0xff;        
    PORTB=0xf0;        
    init_LCD();        // initialization of LCD
    delay_ms(50);        // delay of 50 mili seconds
    LCD_write_string(“sushilprajapati”);    // function to print string on LCD
    
}
 
void init_LCD(void)
{
    LCD_cmd(0x38);        // initialization of 16X2 LCD in 8bit mode
    delay_ms(1);
 
    LCD_cmd(0x01);        // clear LCD
    delay_ms(1);
 
    LCD_cmd(0x0E);        // cursor ON
    delay_ms(1);
 
    LCD_cmd(0x80);        // —8 go to first line and –0 is for 0th position
    delay_ms(1);
    return;
}
 
void LCD_cmd(unsigned char cmd)
{
    LCD_DATA=cmd;
    ctrl =(0<<rs)|(0<<rw)|(1<<en);    
    delay_ms(1);
    ctrl =(0<<rs)|(0<<rw)|(0<<en);    
    delay_ms(50);
    return;
}
 
void LCD_write(unsigned char data)
{
    LCD_DATA= data;
    ctrl = (1<<rs)|(0<<rw)|(1<<en);    
    delay_ms(1);
    ctrl = (1<<rs)|(0<<rw)|(0<<en);    
    delay_ms(50);                
    return ;
}
 
void LCD_write_string(unsigned char *str)    //store address value of the string in pointer *str
{
    int i=0;
    while(str!=’’)                // loop will go on till the NULL character in the string 
    {
        LCD_write(str);                // sending data on LCD byte by byte
        i++;
     }
    return;
}
 

RSS Recent Posts

  • How to power up two stereo audio amplifiers from a single source of power supply August 12, 2022
  • Nokia 5110 HW in Oshonsoft August 12, 2022
  • Drill speed controller fault August 12, 2022
  • Charging shutdown circuit question. August 12, 2022
  • My NE555 chips gone bad August 12, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 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