SHARE
TWEET

Untitled

a guest Feb 20th, 2013 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <avr/io.h>
  2. #define F_CPU 1000000UL
  3. #include <util/delay.h>
  4.  
  5. #define RS      PD0
  6. #define E       PD2
  7. #define RW      PD1
  8. #define LCD_DTA PORTB
  9. #define LCD_CMD PORTD
  10.  
  11. void lcd_cmd(unsigned char cmd)
  12. {
  13.         LCD_DTA = cmd;
  14.         LCD_CMD = (0<<RS);
  15.         LCD_CMD = (0<<RW);
  16.         LCD_CMD = (1<<E);
  17.         _delay_ms(1);
  18.         LCD_CMD = (0<<E);
  19.         _delay_ms(50); 
  20.                
  21.         return;
  22. }
  23.  
  24. void lcd_init()
  25. {
  26.         lcd_cmd(0x38);
  27.         _delay_ms(1);
  28.         lcd_cmd(0x01);
  29.         _delay_ms(1);
  30.         lcd_cmd(0x0f);
  31.         _delay_ms(1);
  32.        
  33.         lcd_cmd(0x80);
  34.         _delay_ms(1);  
  35.         return;
  36. }
  37.  
  38. void lcd_print(unsigned char my_symbol)
  39. {      
  40.         LCD_CMD = (1<<RS);
  41.         LCD_CMD = (0<<RW);
  42.         LCD_CMD = (1<<E);
  43.         LCD_DTA = my_symbol;
  44.        
  45.         _delay_ms(1);
  46.         LCD_CMD = (0<<E);
  47.         _delay_ms(50);
  48. }
  49.  
  50. int main()
  51. {
  52.         DDRD = 0xff;   
  53.         DDRB = 0xff;
  54.         lcd_init();    
  55.         _delay_ms(50);
  56.        
  57.         lcd_print(0x31);
  58.  
  59.         while (1)
  60.         {
  61.                 ;
  62.         }
  63.         return 0;
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top