LoginSignup
0
0

STM8で温度計を作る(STTS751)(I2C)

Last updated at Posted at 2023-12-20

STM8で温度計を作る(STTS751)

目的
STM8のテスト
PE1 PE2

いろいろ
動いてちょっとうれしい

o_cop872.jpg

o_cop873.jpg




//STTS751_STM8_1


//インクルド
#include "I2C.h"


//定義
#define STTS751 0x39


//初期化
void setup()
{

  //シリアルの初期化
  Serial_begin(9600);
  Serial_println_s("START");

  //I2Cの初期化
  I2C_begin();

}//setup


//メインループ
void loop()
{
  uint8_t val; //センサーの値

  //内部アドレスを0番にする
  I2C_write(STTS751, 0);

  //温度の読み出し
  I2C_read(STTS751, 1);
  val = I2C_receive();

  //温度の表示
  Serial_print_s("TEMP=");
  Serial_print_u(val);
  Serial_println();

  delay(1000);//1秒待つ

}//loot



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