Advertisement
tomateblue

I2CMaster

Nov 1st, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <Wire.h>
  2.  
  3. void setup() {
  4.   Wire.begin(); // begin(INT ENDEREÇOS) OPCIONAL P/O MASTER => so inicia comunicação
  5.   Serial.begin(9600);  
  6. }
  7.  
  8. void loop() {
  9.   Wire.requestFrom(8, 6);  
  10.  /*****
  11. requestFrom(int endereço, int numero de bytes); faz uma requisção de nByte byte para o endereço especifico
  12. ***/
  13.  
  14.   while (Wire.available()) {
  15. /**
  16. Wire.available(); => retorna o numero de bytes disponiveis para leitura
  17. **/
  18.     char c = Wire.read(); // Wire.read(); -> lé 1 byte do buffer
  19.     Serial.print(c);        
  20.   }
  21.  
  22.   delay(500);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement