CatPot 2015-2016
/
CatPotI2CSlavetest
test program of I2CSlave
Fork of CatPotI2CSlavetest by
Diff: main.cpp
- Revision:
- 1:178963fb9f75
- Parent:
- 0:dcc9cf1071f1
diff -r dcc9cf1071f1 -r 178963fb9f75 main.cpp --- a/main.cpp Mon Dec 15 07:37:14 2014 +0000 +++ b/main.cpp Mon Dec 15 09:51:15 2014 +0000 @@ -1,3 +1,7 @@ +/* +*動作確認済み +*超音波センサーのデータをマスターに送信 +*/ #include "mbed.h" #include "Ping.h" @@ -21,19 +25,24 @@ char Export[DATA_NUM]={0}; uint8_t cycle=0; - Tiny.address(ADDRESS); - //Tiny.frequency(9600); + int i; + + Tiny.address(ADDRESS);//アドレスの定義 while(1) { Sensor.Send(); wait_ms(30); - Export[cycle%DATA_NUM] = 0xAA;//Sensor.Read_cm(); + Export[cycle%DATA_NUM] = Sensor.Read_cm(); + + cycle++;//配列移動 - cycle++; + myled = (Tiny.receive() == I2CSlave::ReadAddressed);//成功すれば点滅 - switch(Tiny.receive()){ + i = Tiny.receive(); + + switch(i){//変数を介するとうまく動作した. case I2CSlave::ReadAddressed: Tiny.write(Export, DATA_NUM); // Includes null char