閲覧総計:773 (本日:1 昨日:1)
【黴甆】(霾をクリックすると、そこへ斁べます)
液晶ディスプレイへ文字を表示するだけの基本機能の
プログラムを作成し、LEDの稼働を確認した。
また、HI-TOP C PRO(Late modo)のLED表示用関数を作成し、稼働を確認した。 08/01/01
LEDは、東京秋葉原の秋月電子で販売されている16文字×2行表示のLED
SC1602BS-B-XA-GB-K 10800円 を用いた。 08/01/01
http://www.ipic.co.jp/ipi.html
/** * LED表示(基礎) LED 4bit接続の確認 * * LED:SC1602BS-B-XA-GB-K 10800円 * http://www.ipic.co.jp/ipi.html * LEDデータpin D4:RB0 D5:RB1 D6:RB2 D7:RB3 * LED制御pin EN:RC4 RW:RC5 RS:RC6 * 電源:乾電池3本(4.5V) * * 16F84A * Clock: 8.0MHz 内臓発信器使用 * Device Flags: * _INTRC_OSC_NOCLKOUT _WDT_OFF _PWRTE_ON _MCLRE_OFF * _CP_OFF _CPD_OFF _BOR_OFF _IESO_ON _FCMEN_ON * _LVP_OFF _DEBUG_ON _BOR21C _WRT_OFF * *
ed to the LCD EN bit (enable)
* * To use these routines, set up the port I/O (TRISA, TRISD) then * call lcd_init(), then other routines as required. * */ #ifndef _XTAL_FREQ // Unless specified elsewhere, 8MHz system frequency is assumed #define _XTAL_FREQ 8000000 #endif #include <htc.h> #include "lcd.h" #define LCD_RS RC6 #define LCD_RW RC5 #define LCD_EN RC4 #define LCD_DATA PORTB #define LCD_STROBE() ((LCD_EN = 1),(LCD_EN=0)) /* write a byte to the LCD in 4 bit mode */ void lcd_write(unsigned char c) { __delay_us(40); LCD_DATA = ( ( c >> 4 ) & 0x0F ); LCD_STROBE(); LCD_DATA = ( c & 0x0F ); LCD_STROBE(); } /* * Clear and home the LCD */ void lcd_clear(void) { LCD_RS = 0; lcd_write(0x1); __delay_ms(2); } /* write a string of chars to the LCD */ void lcd_puts(const char * s) { LCD_RS = 1; // write characters while(*s) lcd_write(*s++); } /* write one character to the LCD */ void lcd_putch(char c) { LCD_RS = 1; // write characters lcd_write( c ); } /* * Go to the specified position */ void lcd_goto(unsigned char pos) { LCD_RS = 0; lcd_write(0x80+pos); } /* initialise the LCD - put into 4 bit mode */ void lcd_init() { char init_value; ADCON1 = 0x06; // Disable analog pins on PORTA init_value = 0x3; TRISB=0; TRISC=0; LCD_RS = 0; LCD_EN = 0; LCD_RW = 0; __delay_ms(15); // wait 15mSec after power applied, LCD_DATA = init_value; LCD_STROBE(); __delay_ms(5); LCD_STROBE(); __delay_us(200); LCD_STROBE(); __delay_us(200); LCD_DATA = 2; // Four bit mode LCD_STROBE(); lcd_write(0x28); // Set interface length lcd_write(0xF); // Display On, Cursor On, Cursor Blink lcd_clear(); // Clear screen lcd_write(0x6); // Set entry Mode }
●↓lcd.cの設定(分割コンパイル)
★この情報は役に立つ?