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?

More than 1 year has passed since last update.

(デカ文字)ESP32でカラー液晶、温度計を作って遊ぶ2(センサー仕様)

Last updated at Posted at 2023-10-15

(デカ文字)ESP32でカラー液晶、温度計を作って遊ぶ2(完成するか不明)

参考

テスト結果

o_cop676.jpg

o_cop677.jpg

o_cop678.jpg

stm32g031側の処理



//I2C_5851_HS_031_color1

#include <Arduino.h>
#include <Wire.h>
#include <HardwareSerial.h>

#define S5851A 0x48


//初期化
void setup()
{

  delay(3000); //not delete

  //シリアルの初期化
  Serial.setTx(PA2_ALT1);
  Serial.setHalfDuplex();
  Serial.begin(9600);

  //i2cの初期化
  Wire.setSDA(PA12);
  Wire.setSCL(PA11);
  Wire.begin(); //pa12 pa11

} //setup


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

  //0番目のレジスター
  Wire.beginTransmission(S5851A);
  Wire.write(0);
  Wire.endTransmission();
  delay(1);

  //温度の読み込み
  int s; //センサーの値
  
  Wire.requestFrom(S5851A, 1);

  //1
  while(Wire.available())  {    // 要求より短いデータが来る可能性あり
    s = (int)Wire.read();       // 1バイトを受信
  }//while

  //sのエラー処理
  if( (s < 0) || (s > 99)) { s = 99;}


  //1の桁と10の桁を分離して二進化十進へ
  int bh,bl,bc;

  bh = s / 10;
  bl = s - (bh * 10);

  bc = (bh*16)+bl;

  //温度の表示 debug
  //Serial.print( "[" );
  //Serial.print( s );
  //Serial.print( "]" );
  //Serial.println();


  //温度の表示 キャストする 強制文字化
  //Serial.print( "<" ); //debug
  Serial.print( (char)bc );
  //Serial.print( ">" ); //debug


  //1秒の待ち
  delay(1000);

} //loop



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?