1
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?

I2C温度センサー TC74A0 で遊ぶ。(最終章)(温度表示)(いろいろ、キャスト(型変換))(TC74A0-3.3VCTTR)

Last updated at Posted at 2025-07-21

いろいろ注意

  • 過去ログを見よ!!!
  • 符号の処理をしているのでめんどい(たぶん、大丈夫)
  • いろいろ アイス1本ぐらいの時間で出来た。
  • エラーは、88 (察してほしい(88℃との区別は、つかない。))(答え)(7セグの全点灯

目的

  • 温度をシリアルポートに出力

結果

o_coq923.jpg

o_coq924.jpg

image_original - 2025-07-21T044835.823.jpg

プログラム




//I2C_TC74A0_TEST1_UNO_1


//インクルド
#include <Arduino.h>
#include <Wire.h> //I2C library


//定義
#define I2C_ADD 0x48


//初期化
void setup()
{  

  //i2cの初期化
  Wire.begin(); //uno

  //シリアルポートの初期化
  Serial.begin(9600);

} //setup


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

  //0番目のレジスター (I2Cサブアドレス)
  Wire.beginTransmission(I2C_ADD);
  Wire.write(0);
  Wire.endTransmission();
  delay(1);

  //温度の読み込み
  char tempval = 88; //温度
  Wire.requestFrom(I2C_ADD, 1);
  while(Wire.available())  {    // 要求より短いデータが来る可能性あり
    tempval = Wire.read(); // 1バイトを受信
  }//while


  //tempval = 0xff; //debug -1
  //tempval = 0x0;  //debug 0
  //tempval = 0x80; //debug -128
  //tempval = 24;   //debug


  //表示
  Serial.println( (int)tempval );

  delay(1000); //1秒待つ

} //loop




1
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
1
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?