Keil Studio , LPC812MAXと超音波距離センサーHC-SR04でOLED SSD1306



x 過去ログをみよ
x ソースは、長め

x @sasakisanさんの記事を非営利、研究目的で参考にして移植しました。



目的
HC_SR04からのPWMの受信
Keil Studio用に焼き直し
OLEDにデカ文字表示
SMALL_SSD1308_128x64_I2C ライブラリ使用



![o_cop382.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/25422e36-6bf9-16e8-078c-f66a11f1f47b.jpeg)




```c++



//Keil Studio   ( mbed2 )
//oled_HC_SR04_32x64_812_1


#include "mbed.h"
#include "SSD1308.h"

//5851
#define ADDR        (0x90) //  address

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

// ビットマップデータ
char databytes1[] =
    {
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xe1, 0x87, 0xff, 
  0xff, 0xcf, 0xf3, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe,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 
  0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 
  0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 
  0xff, 0xe0, 0x07, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xc0, 0x03, 0xff, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xe1, 0x87, 0xff, 
  0xff, 0xcf, 0xf3, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xff, 0x7f, 0xfe, 0x7f, 0xff, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 
  0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xf9, 0xff, 
  0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xf8, 0x07, 0xff, 0xff, 0xf8, 0x07, 0xff, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 
  0xff, 0xcf, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 
  0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 
  0xff, 0x1f, 0xe0, 0x7f, 0xff, 0x1f, 0xe0, 0x7f, 0xff, 0x80, 0x00, 0x7f, 0xff, 0x80, 0x00, 0x7f, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xe1, 0x87, 0xff, 
  0xff, 0xcf, 0xf3, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 
  0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xf9, 0xff, 
  0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xf0, 0x07, 0xff, 
  0xff, 0xf0, 0x07, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xe3, 0xff, 
  0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 
  0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 
  0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 
  0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x7f, 0xff, 0x3f, 0xff, 0x7f, 
  0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x8f, 0xfc, 0xff, 0xff, 0x8f, 0xfc, 0xff, 
  0xff, 0xc3, 0xe1, 0xff, 0xff, 0xc3, 0xe1, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xe0, 0x03, 0xff, 
  0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xc3, 0xff, 
  0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0x8f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 
  0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 
  0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xe1, 0x9f, 0xff, 0xff, 0xe1, 0x9f, 0xff, 
  0xff, 0xc3, 0x9f, 0xff, 0xff, 0xc3, 0x9f, 0xff, 0xff, 0x87, 0x9f, 0xff, 0xff, 0x87, 0x9f, 0xff, 
  0xff, 0x1f, 0x9f, 0xff, 0xff, 0x1f, 0x9f, 0xff, 0xff, 0x3f, 0x9f, 0xff, 0xff, 0x3f, 0x9f, 0xff, 
  0xfe, 0x3f, 0x9f, 0xff, 0xfe, 0x3f, 0x9f, 0xff, 0xfe, 0x7f, 0x9f, 0xff, 0xfe, 0x7f, 0x9f, 0xff, 
  0xfe, 0x7f, 0x1f, 0x7f, 0xfe, 0x7f, 0x1f, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 
  0xfe, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x7f, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 
  0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 
  0xfe, 0x3f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 
  0xff, 0x83, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xe0, 0x07, 0xff, 
  0xff, 0xf0, 0x07, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xe3, 0xff, 
  0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 
  0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 
  0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 
  0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 
  0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x8f, 0xfc, 0xff, 0xff, 0x8f, 0xfc, 0xff, 
  0xff, 0xc3, 0xe1, 0xff, 0xff, 0xc3, 0xe1, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xe0, 0x03, 0xff, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xe1, 0x87, 0xff, 
  0xff, 0xcf, 0xf3, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f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ff, 0x3f, 0xff, 0x3f, 0xff, 0x7f, 0xff, 0x3f, 0xff, 0x7f, 
  0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x8f, 0xfc, 0xff, 0xff, 0x8f, 0xfc, 0xff, 
  0xff, 0xc3, 0xe1, 0xff, 0xff, 0xc3, 0xe1, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xe0, 0x03, 0xff, 
  0xfc, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x3f, 
  0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 
  0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf8, 0xff, 
  0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xe3, 0xff, 
  0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xcf, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 
  0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 
  0xff, 0xf8, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 
  0xff, 0xe1, 0xff, 0xff, 0xff, 0xe1, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 
  0xff, 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 0x7f, 0xff, 0xff, 0xfe, 0x7f, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 
  0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 
  0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xc1, 0xff, 
  0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xff
    };

int gop[8][8] = {{0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0},

                 {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}};

unsigned char bbh[]
    // 1122
    = {0, 0, 0, 0, 0, 0, 0, 0};


void p_m270(char ttt[]) {
  char cc;
  for (int ii = 0; ii < 8; ii++) {
    cc = ttt[ii];
    gop[ii][7] = cc & 0x1;    cc = cc >> 1;
    gop[ii][6] = cc & 0x1;    cc = cc >> 1;
    gop[ii][5] = cc & 0x1;    cc = cc >> 1;
    gop[ii][4] = cc & 0x1;    cc = cc >> 1;

    gop[ii][3] = cc & 0x1;    cc = cc >> 1;
    gop[ii][2] = cc & 0x1;    cc = cc >> 1;
    gop[ii][1] = cc & 0x1;    cc = cc >> 1;
    gop[ii][0] = cc & 0x1;
  } // for
} // p_m270


void p_out(unsigned char ttt[]) {
  char cc;
  for (int ii = 0; ii < 8; ii++) {
    cc = 0;
    cc = cc + (gop[0][ii] * 1);
    cc = cc + (gop[1][ii] * 2);
    cc = cc + (gop[2][ii] * 4);
    cc = cc + (gop[3][ii] * 8);
    cc = cc + (gop[4][ii] * 16);
    cc = cc + (gop[5][ii] * 32);
    cc = cc + (gop[6][ii] * 64);
    cc = cc + (gop[7][ii] * 128);
    ttt[ii] = cc;
  } // for
} // p_out


//32x64
void bitmap32x64( SSD1308 *oled, uint8_t * databytes9,   int p_row ,  int p_col ) {

  int o_row = 0;
  int o_col = 0;
  int kk = 0;

  o_row = p_row;

  for (int ii = 0; ii < 8; ii++) {

    o_col = p_col;

    for (int jj = 0; jj < 4; jj++) {

      char koi[8];

      koi[0] = *(databytes9 + kk + 0);
      koi[1] = *(databytes9 + kk + 4);
      koi[2] = *(databytes9 + kk + 8);
      koi[3] = *(databytes9 + kk + 12);

      koi[4] = *(databytes9 + kk + 16);
      koi[5] = *(databytes9 + kk + 20);
      koi[6] = *(databytes9 + kk + 24);
      koi[7] = *(databytes9 + kk + 28);

      kk = kk + 1;

      p_m270(koi);
      p_out(bbh);

      oled->writeBitmap((uint8_t *)bbh, 
                        o_row,
                       (o_row + 1 - 1),
                        o_col,
                       (o_col + 8 - 1));

      o_col = o_col + 8;

    } // for jj

    o_row = o_row + 1;

    kk = kk + 7 * 4;

  } // for ii


} // bitmap32x32


//超音波距離センサー系の定義
#define HIGH 1
DigitalOut TRIG(P0_17);   //green   D8
DigitalIn  ECHO(P0_7);    //red     D7
//タイマーの設定
Timer t;


//PA_5のオン時間をusで測る　今のところ引数は、無効
int pulseIn(int pin1,int pu1,int timeout1)
{

    t.reset();//タイマーの開始

    //タイムアウトの設定
    //timeout1 = 32000000;
    timeout1 = 100000;    //28ms
    //timeout1 = 1000;   //degbu

    //while(PA_5 == 0) {} //オフの間は、無限ループ

loop_s1:
    timeout1--;
    //                                     5432109876543210
    if (     (~(LPC_GPIO_PORT->PIN0))  & 0b0000000010000000     ) {
        if ( timeout1 ) {
            goto loop_s1;
        }
    }


    int sd = t.read_us();//測定開始

    //タイムアウトの設定
    //timeout1 = 32000000;
    timeout1 = 100000;     //28ms
    //timeout1 = 1000;   //degbu

    //while(PA_5 != 0) {} //オンの間は、無限ループ

loop_in1:
    timeout1--;
    //                               5432109876543210
    if (   (LPC_GPIO_PORT->PIN0) & 0b0000000010000000   ) {
        if( timeout1 ) {
            goto loop_in1;
        }
    }


    return(t.read_us()-sd);//測定終了

}//pulseIn


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

  wait_ms(500); // 0.5秒の待ち

  // Instantiate OLED
  SSD1308 oled = SSD1308(&i2c, SSD1308_SA0);


  int cn[4];  //桁
  int x = 46; //数値

  unsigned long times; //測定時間
  int distance;        //長さ　単位は、mm

  //タイマーの開始
  t.start();

  // GPIOの初期化
  TRIG = 0;


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


    // 超音波を発生させる
    TRIG = 1;
    wait_us(10);
    TRIG = 0;

    // 超音波を受け取る
    times = pulseIn( 5, HIGH,2000000);

    // times = (unsigned long)7700/2; //debug
    // times = 1177; // debug 1ms 20.0cm
    // times = 942;//debug 1ms 16.0cm

    //時間を距離に変換する　音は、1秒間に約340メートル進む
    //速さx時間は距離
    //まず往復なので1/2にする
    // times/2
    // 340 x (times / 1000) 単位が秒なのでそろえてあげる
    // distance = (int)(times * 0.017);
    distance = (int)((times * ((unsigned long)(17))) / 100);



    x = distance; //距離の転記



//10の割り算 0から9999までは、正しい。 stm32
#define DIV10(n) (((n*409)+((n*154)>>8))>>12)

    cn[3]    =  (  x - (DIV10(x) * 10)  );  // '0'+(d%10)
    x = DIV10(x);
    cn[2]    =  (  x - (DIV10(x) * 10)  );  // '0'+(d%10)
    x = DIV10(x);
    cn[1]    =  (  x - (DIV10(x) * 10)  );  // '0'+(d%10)
    cn[0]    =   DIV10(x);                  // '0'+(d/10)

    for(int ii=0;ii<4;ii++){

       bitmap32x64( &oled,(uint8_t *) ( databytes1+(cn[ii] *(32/8)*64)  ), 0 ,   ii*32 );

    }//for

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

  }//while

} // main




```