Who_am_I readtest
Dependencies: mbed
main.cpp@0:213f9a70f694, 2018-07-12 (annotated)
- Committer:
- ponpoko1939
- Date:
- Thu Jul 12 12:49:50 2018 +0000
- Revision:
- 0:213f9a70f694
Who_am_I read
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ponpoko1939 | 0:213f9a70f694 | 1 | #include "mbed.h" |
ponpoko1939 | 0:213f9a70f694 | 2 | |
ponpoko1939 | 0:213f9a70f694 | 3 | I2C i2c(p9,p10); |
ponpoko1939 | 0:213f9a70f694 | 4 | Serial pc(USBTX, USBRX); |
ponpoko1939 | 0:213f9a70f694 | 5 | const int addr = 0x68;//KP-9250のスレーブアドレス |
ponpoko1939 | 0:213f9a70f694 | 6 | char cmd[2]; |
ponpoko1939 | 0:213f9a70f694 | 7 | char get[2]; |
ponpoko1939 | 0:213f9a70f694 | 8 | |
ponpoko1939 | 0:213f9a70f694 | 9 | int main() { |
ponpoko1939 | 0:213f9a70f694 | 10 | cmd[0] = 0x75; |
ponpoko1939 | 0:213f9a70f694 | 11 | i2c.write(addr,cmd,1); |
ponpoko1939 | 0:213f9a70f694 | 12 | i2c.read(addr,get,1); |
ponpoko1939 | 0:213f9a70f694 | 13 | pc.printf("%d\n\r",get[0]); |
ponpoko1939 | 0:213f9a70f694 | 14 | } |