Created
August 6, 2019 14:07
-
-
Save ArduinoDiscordBot/f22137844aabba77a9e54b79cb1e4f35 to your computer and use it in GitHub Desktop.
Code by Josh#5514 - Tue Aug 06 2019 14:07:18 GMT+0000 (Coordinated Universal Time)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
void setup() { | |
Serial.begin(9600); /* begin serial for debug / | |
Wire.begin(D1, D2); / join i2c bus with SDA=D1 and SCL=D2 of NodeMCU / | |
} | |
void loop() { | |
Wire.beginTransmission(8); / begin with device address 8 / | |
Wire.write("Hello Arduino"); / sends hello string / | |
Wire.endTransmission(); / stop transmitting / | |
Wire.requestFrom(8, 13); / request & read data of size 13 from slave / | |
while(Wire.available()){ | |
char c = Wire.read(); | |
Serial.print(c, HEX); | |
Serial.println(); | |
} | |
Serial.println(); | |
delay(1000); | |
} | |
leonardo's code | |
'''#include <Wire.h> | |
void setup() { | |
Wire.begin(8); / join i2c bus with address 8 / | |
Wire.onReceive(receiveEvent); / register receive event / | |
Wire.onRequest(requestEvent); / register request event / | |
Serial.begin(9600); / start serial for debug / | |
} | |
void loop() { | |
delay(100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment