Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:bdd449e55907
- Child:
- 1:f77859e74071
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Feb 27 12:45:08 2017 +0000 @@ -0,0 +1,48 @@ + // Simple I2C responder + #include <mbed.h> + + + +I2CSlave slave(D14, D15); + + int main() { + + DigitalOut myLED (LED2); + + + + + slave.address(0x14); + + + + char buf[10]; + + + + + while (1) { + int i = slave.receive(); + switch (i) { + // case I2CSlave::ReadAddressed: + + // slave.write(5); // Includes null char + + // myLED=0; + // break; + //case I2CSlave::WriteGeneral: + + //to implement + case I2CSlave::WriteAddressed: + + slave.read(buf, 10); + + if (buf ==1){ + myLED=1; + } + + break; + } + for(int i = 0; i < 10; i++) buf[i] = 0; // Clear buffer + } + }