Arduino本体と重ねて接続する。両側のピンのほかにUSB端子と逆側の中央付近のピンにも差し込むようになっているので、注意深く差し込む。すべてのピンを挿すようになっているが、実際には、デジタルピンの4と9から13を使用している(もちろん、電源5VとGNDも使っている)。アナログピン、およびデジタルピンの2, 3, 5, 6, 7, 8は他の用途に利用可能である。これらのピンを使う場合には、ピンだけの基盤を間に挟む。ピンが足りないが、気にしなくてよい。
#include "SPI.h" #include "Adafruit_GFX.h" #include "Adafruit_ILI9341.h" #define TFT_DC 9 #define TFT_CS 10 Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
tft.begin();
tft.color565( r, b, g );で指定する。r, g, bはそれぞれ0から255の数。
tft.setRotation( angle );angleは0=縦・USB端子上、1=横・USB端子左、2=縦・USB端子下、左3=横・USB端子右
tft.width() tft.height();
tft.fillScreen( color );
tft.drawLine( x1, y1, x2, y2, color );横線
tft.drawFastHLine( x1, y, x2, color );縦線
tft.drawFastVLine( x, y1, y2, color );長方形
tft.drawRect( x, y, w, h, color );長方形塗りつぶし
tft.fillRect( x, y, w, h, color );角丸長方形
tft.drawRoundRect( x, y, w, h, r, color );角丸長方形塗りつぶし
tft.fillRoundRect( x, y, w, h, r, color );円
tft.drawCircle( x, y, r, color );円塗りつぶし
tft.fillCircle( x, y, r, color );三角形
tft.drawTriangle( x, y, r, color );三角形塗りつぶし
tft.fillTriangle( x, y, r, color );
tft.setTextSize( size );文字色の設定
tft.setTextColor( color ); tft.setTextColor( color, background );描画位置の指定
tft.setCursor( x, y );文字の描画
tft.println( string );