Guest User

Untitled

a guest
Dec 17th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. void loop() {
  2. int serialIndex = 0;
  3. if(Serial.available() > 0){
  4. while (0 < Serial.available()) { // loop through all the received bytes
  5. String bufferString;
  6. uint8_t bufferInt;
  7. bufferString = Serial.readStringUntil(',');
  8. bufferInt = bufferString.toInt();
  9. serialBuffer[serialIndex] = bufferInt; // put current index byte in array
  10. serialIndex ++; // add index.
  11. }
  12. sendBytes();
  13. }
  14. delay(50);
  15. }
  16.  
  17. void sendBytes(){
  18. for(int i = 0; i<boards; i++){
  19. // int i2cIndex = i*12;
  20. // for(int j = 0; j <12; j++){
  21. // i2cBuffer[j] = serialBuffer[j+i2cIndex];
  22. // }
  23. Wire.beginTransmission(i+1);
  24. Wire.write(serialBuffer, 12);
  25. Wire.endTransmission();
  26. }
  27. }
  28.  
  29. if(Serial.available() > 0){
  30.  
  31. if(Serial.available() == 30){
Add Comment
Please, Sign In to add comment