ILI9163V(ST7735のような)で遊ぶ2(2週間から2か月の長期記事)(なんかでた)ATM01177B3A



ILI9163V(ST7735のような)で遊ぶ2(2週間から2か月の長期記事)(なんかでた)ATM01177B3A


目的
遊ぶ


いきなり、5ピン分削ると
10ピンに収まる(省略)(1,2,3,4,5)
小一時間かけて地道にゆびを切らない様に
カッターナイフで
削って行くとピッタリ収まる
450円+200円で収まる
LEDのあそーどは、別からとる


配線 データシート確認の事

13 CLK
12
11 DATA
10 CS
9 REST
8 RS(DC)

LEDアソート゛は、330オ-ムで3.3V
LEDカソードは、GND


![o_cop824.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/940e7489-608e-0cbe-5c19-505da705a02a.jpeg)





プログラム


```c++






//GPIO_st7735_SPI_TEST1_UNO_1

// 'sentakubasami', 128x160px
//static const unsigned char PROGMEM databytes[(128/8)*160];


//GPIO
#define GPIO_D13(s) digitalWrite(13,s)
#define GPIO_D12(s) digitalWrite(12,s) //未使用
#define GPIO_D11(s) digitalWrite(11,s)
#define GPIO_D10(s) digitalWrite(10,s)
#define GPIO_D9(s)  digitalWrite(9,s)
#define GPIO_D8(s)  digitalWrite(8,s)


void GPIO_D0_D7(int s)
{
      digitalWrite(13,0);
  digitalWrite(11, (s >> 7) & 0x01);
      digitalWrite(13,0);
      digitalWrite(13,1);
      digitalWrite(13,0);
  digitalWrite(11, (s >> 6) & 0x01);
      digitalWrite(13,0);
      digitalWrite(13,1);
      digitalWrite(13,0);
  digitalWrite(11, (s >> 5) & 0x01);
      digitalWrite(13,0);
      digitalWrite(13,1);
      digitalWrite(13,0);
  digitalWrite(11, (s >> 4) & 0x01);
      digitalWrite(13,0);
      digitalWrite(13,1);
      digitalWrite(13,0);
  digitalWrite(11, (s >> 3) & 0x01);
      digitalWrite(13,0);
      digitalWrite(13,1);
      digitalWrite(13,0);
  digitalWrite(11, (s >> 2) & 0x01);
      digitalWrite(13,0);
      digitalWrite(13,1);
      digitalWrite(13,0);
  digitalWrite(11, (s >> 1) & 0x01);
      digitalWrite(13,0);
      digitalWrite(13,1);
      digitalWrite(13,0);
  digitalWrite(11, s & 0x01);
      digitalWrite(13,0);
      digitalWrite(13,1);
      digitalWrite(13,0);
} //GPIO_D0_D7


//ライト

void LCD_Write_CMD(int a)
{

  GPIO_D10(0);//CS=0; 12
  GPIO_D8(0); //A0=0; 9
      GPIO_D0_D7(a);//P1=a; data SPI SPI
  GPIO_D10(1);//CS=1; 12

} //LCD_Write_CMD

void LCD_Write_Data(int a)
{

  GPIO_D10(0);//CS=0; 12
  GPIO_D8(1); //A0=1; 9
      GPIO_D0_D7(a);//P1=a; data SPI SPI
  GPIO_D10(1);//CS=1; 12


} //LCD_Write_Data


//画面の書き込み
///void output_pict(unsigned char * pi)
///{
///  //画面の書き込み開始
///  LCD_Write_CMD(0x2C); //memory write
///
///  GPIO_D12(0);//CS=0; 12
///  GPIO_D9(1);//A0=1; 9
///  GPIO_D0_D7(0xff);//P1=a; data
///
///  int jjk=0,vg=0;
///  int hp[8]={0x80,0x40,0x20,0x10,  0x08,0x04,0x02,0x01};
///  for (int i = 0; i < 160; i++) {
///    for (int j = 0; j < (128/8); j++) {
///
///      vg=pi[jjk];
///      for(int k=0;k < 8;k++){
///        if ( ( vg & hp[k]) == 0 ) {GPIO_D0_D7(0x00);} else {GPIO_D0_D7(0xff);}
///
///        GPIO_D10(0);//WRB=0; 10
///        GPIO_D10(1);//WRB=1; 10
///
///        GPIO_D10(0);//WRB=0; 10
///        GPIO_D10(1);//WRB=1; 10
///      }//k
///      jjk++;
///
///    } //j
///  }//i
///
///  GPIO_D12(1);//CS=1;  12
///
///} //output_pict


//液晶の初期化処理
void TXDT144TF_ST7735S_Init(void)
{

  //----------  ST7735S Reset Sequence  --------//

  GPIO_D8(1);//LCD_RESET=1;

  delay(1); //Delay 1ms

  GPIO_D8(0);//LCD_RESET=0;

  delay(1); //Delay 1ms

  GPIO_D8(1);//LCD_RESET=1;

  delay(120); //Delay 120ms

  LCD_Write_CMD(0x01);//SOFTWARE RESET
  delay(50);

  LCD_Write_CMD(0x01);//SOFTWARE RESET
  delay(50);

  LCD_Write_CMD(0x11);//SLEEP OUT
  delay(200);

  LCD_Write_CMD(0x29);//display on
  delay(100);

  LCD_Write_CMD(0x3a);//Interface pixel format
  LCD_Write_Data(0x05);//16bit mode
  delay(100);

} //TXDT144TF_ST7735S_Init


//初期化
void setup() {

  //ポートのモード設定　アウトプットモード
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT); //未使用
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);


  //ポートの初期化
  GPIO_D13(1);//SPI_DATA=1
  GPIO_D11(0);//SPI_CLK=1

  GPIO_D10(1);//CS=1
  GPIO_D9(1);//RESET=1
  GPIO_D8(0);//RS=0



  delay(500); //0.5秒待つ

  //液晶の初期化処理
  TXDT144TF_ST7735S_Init();

  //画面の書き込み開始
  LCD_Write_CMD(0x2C); //memory write
    delay(1);
  for(int ii=0;ii<(128*8*2);ii++){
     LCD_Write_Data(0xff);
  }

  //洗濯ばさみの絵の表示
  //output_pict( (unsigned char *)databytes );

} //setup


//メインループ
void loop() {

//  digitalWrite(PB7, HIGH);
//  delay(200); //0.2秒待つ

//  digitalWrite(PB7, LOW);
//  delay(200); //0.2秒待つ

} //loop






```