#include #define I2CADDRESS 0x40 // x100 0000 7bit address #define LED 12 uint8_t buf[6]; void setup() { Wire.begin(2, 14); //SDA:IO2 SCK:IO14 Wire.setClock(100000); //default 100kbps Serial.begin(115200); Serial.println(); Serial.println(); Serial.println("I2C Master:ESP8266 Slave:0x40(PIC16F1503)"); for (uint8_t i = 0; i < 6; i++) buf[i] = 0; } void I2C_PIC() { unsigned char c; char k; Wire.beginTransmission(I2CADDRESS); Wire.write(0xa0); Wire.write(0x0a); Wire.write(0x41); Wire.endTransmission(); Wire.requestFrom(I2CADDRESS, 4); Serial.print(" RESPONSE:"); for (k = 0; k < 4; k++) { c = Wire.read(); Serial.print(c); Serial.print(" "); } Serial.println(); } void loop() { for (int i = 0; i < 5; i++) { I2C_PIC(); delay(5); } while (1) {delay(10);} //WDT Reset防止 }