MasterTest

Dependencies:   mbed

main.cpp

Committer:
ryuna
Date:
2014-12-15
Revision:
0:cafd8b891544

File content as of revision 0:cafd8b891544:

#include "mbed.h"

#define ADDRESS 0xA0
#define DATA_NUM 5

DigitalOut myled(LED1);
I2C Mbed(p9, p10);//sda,scl
Serial pc(USBTX,USBRX);

int main() {
    
    char STONE[DATA_NUM];
    
    uint8_t val;
    
    //Mbed.frequency(9600);
    
    while(1) {
        
        val = Mbed.write(ADDRESS, NULL, DATA_NUM);   // PINGデータを要求
        myled = !val;
        wait_ms(5);
        val = Mbed.read(ADDRESS, STONE, DATA_NUM);// PINGデータを受信
        
        
        pc.printf("%d\n", STONE[0]);
        wait_ms(0.1);
    }
}