LoginSignup
0
0

More than 1 year has passed since last update.

LPC812MAXとS-5851Aで温度をシリアルに出力(小数点)

Last updated at Posted at 2022-09-10

x mbed2リビジョン144
x リビジョンを変更できる人むけ

目的
精度の関係で意味は、ないけど小数部も受信する
わかりやすくて見やすいから小数点以下2ビットとする0,.25,.50,.75

  • o_con527.jpg -

o_con527.jpg

o_con738.jpg




// SER_test1_5851_812_1

#include "mbed.h"

//         TX    RX
Serial pc(P0_4, P0_0); //812

//       SDA    SCL
I2C i2c(P0_10, P0_11); //812

//メイン関数
int main()
{

    char data_read[8];  //バッファー

    //無限ループ
    while(1) {

        //初期化
        //set address 0
        i2c.write(0x90, "\000", 1);
        wait_ms(1); //addres 0

        //温度の読み込み
        // Read temperature register
        i2c.read(0x90 | 1, data_read,2);
        wait_ms(1);

        //温度の表示
        pc.printf("%2d", data_read[0] );
        char  *f4[] = {".0", ".25", ".5", ".75"};
        pc.printf( f4[data_read[1]>>6] );
        pc.printf( "\r\n" );

        //1秒待つ
        wait_ms(1000);

    }//while

}//main





o_con833.jpg

-20-

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