ATtiny+74HC595でLCDを使う(LiquidCrystal595)


ATtiny+74HC595(シフトレジスター)でのLCD表示を調べていたら、LiquidCrystal595ライブラリを見つけましたの で紹介します。

こちらから Serial-LCDライブラリをダウンロードします。
展開したら LiquidCrystal595 フォルダーだけライブラリーフォルダーに移動します。

【ATtiny84@1MHz】
以下の結線でexamplesフォルダーにある LCD595HelloWorld_pde が動きます。
FemtoCowのAddOnを使ってコンパイルしています。



【ATtiny85@1MHz】
以下の結線でexamplesフォルダーにある LCD595HelloWorld_pde が動きます。



【ATtiny861@1Mhz】
以下の結線でexamplesフォルダーにある LCD595HelloWorld_pde が動きます。



【ATtiny4313@1MHz】
以下の結線でexamplesフォルダーにある LCD595HelloWorld_pde が動きます。



以下のスケッチを使用してモデルごとのパフォーマンスを測定してみました。

/* -----------------------------------------------------------------------------------
 * Adaption of the LCD4Bit library shipped with Arduino 22
 * for use with 74C595 shift register adapter board found on:
 * http://www.stephenhobley.com
 
 * Code adaption by Steve Hobley - February 2011

 /*---Shift Register 74HC595---
 * [SR Pin 14 (DS)]    to Arduino pin - Yellow wire [datapin]
 * [SR Pin 12 (ST_CP)] to Arduino pin - Green wire  [latchpin]
 * [SR Pin 11 (SH_CP)] to Arduino pin - White wire  [clockpin]
 * Black wire to Ground
 * Red wire to +5v

 -----Shift Reg to LCD--------
 * SR Pin 15  - ENABLE        10000000
 * SR Pin 4   - D4            00000010
 * SR Pin 3   - D5            00000100
 * SR Pin 2   - D6            00001000
 * SR Pin 1   - D7            00010000
 * SR Pin 5   - MOSFET / LED1 00100000
 * SR Pin 6   - LED 2         01000000
 * SR Pin 7   - RS            00000001
 *
 * ----------------------------------------------------------------------------------- */
// include the library code:
#include <LiquidCrystal595.h>

// initialize the library with the numbers of the interface pins + the row count
// datapin, latchpin, clockpin, num_lines
LiquidCrystal595 lcd(2,3,4);

void setup()
{
  lcd.begin(16,2);
}

void loop()
{
  static int number=0;
  char buf[21];

  if (number < 100) {
    lcd.setCursor(0, 0);
  // Print a message to the LCD.
    sprintf(buf,"Hello, World %03d!",number++);
    lcd.print(buf);

  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
    lcd.setCursor(0, 1);
  // print the number of seconds since reset:
    lcd.print(millis());
  }
}

モデル 処理時間(ミリ秒) (参考)ShiftLCDライブラリ
ATtiny84 55111 47233
ATtiny85 51832 44408
ATtiny861 48711 41756
ATtiny4313 44179 37877

ライブラリソースを見てみましたが、shiftOut() を使わずに、完全なbitBangingで処理していました。

続く...