0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Adafruit MCP23017 Arduino Libraryのアプデでエラーが出た

Posted at

↑の記事を参考に↓のサンプルコードでMCP23017を制御しているときに

サンプルコード
// Arduino入門編㉚ I/OエキスパンダーMCP23017を使ってみる!
// https://burariweb.info
// デジタル出力のテスト

#include <Wire.h>                  // ライブラリのインクルード
#include "Adafruit_MCP23017.h"
Adafruit_MCP23017 mcp;             // MCPライブラリのオブジェクトを作成

void setup() {
  
  Wire.begin();
  mcp.begin();                     // MCP23017のI2Cアドレスを0x00に設定(0x00は省略可)

  for (int i = 8; i <= 15; i++) {  // 8~15(GPB0~GPB7)を出力に設定
    mcp.pinMode(i, OUTPUT);
  }

}

void loop() {

  for (int i = 8; i <= 15; i++) {  // 8~15(GPB0~GPB7)に接続されたLEDを点灯
    mcp.digitalWrite(i, HIGH);
    delay(30);
  }

  for (int i = 8; i <= 15; i++) {  // 8~15(GPB0~GPB7)に接続されたLEDを消灯
    mcp.digitalWrite(i, LOW);
    delay(30);
  }
}
Compilation error: Adafruit_MCP23017.h: No such file or directory

と出てきてしまいました。
Adafruit MCP23017 Arduino Libraryのバージョンを2.3.2から1.3.0に落とすと無事作動するようです。

調べてみるとAdafruit MCP23017 Arduino Libraryのvar1.x.xとvar2.x.xの間で宣言が

#include "Adafruit_MCP23017.h"

から

#include "Adafruit_MCP23X17.h"

に変わったようです。
それに伴い

1.x.x 2.x.x 役割
Adafruit_MCP23017 mcp; Adafruit_MCP23X17 mcp; MCPライブラリのオブジェクトを作成
mcp.begin(); mcp.begin_I2C(); MCP23017のI2Cアドレス設定

となったようです。
まあこの情報は調べたら結構出てくるのでちゃんと調べなかった私が悪いんですけどね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?