Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

ArrayIndexOutofBoundsException??

$
0
0

I cannot see where this error comes from in this sketch: Any help would be appreciated . . .

import processing.io.*; I2C i2c;

void setup() { size(420, 420); i2c = new I2C(I2C.list()[0]); background(255); }

float celsius;

void draw() { for (int pixel = 0; pixel < 64; pixel++) {

i2c.beginTransmission(0x68);
i2c.write(0x80);
i2c.endTransmission();

i2c.beginTransmission(0x68);
i2c.write(0x68);
byte[] in = i2c.read(2);
int lowerLevel = in[0];
int upperLevel = in[1];
i2c.endTransmission();

int temperature = ((upperLevel << 8) | lowerLevel);
if (temperature > 2047) {
  temperature = temperature - 4096;
}

celsius = temperature * 0.25;
print(celsius);
print(" ");

if ((pixel + 1) % 8 == 0) {
  print("\r\n");
}

} }


Viewing all articles
Browse latest Browse all 2896

Trending Articles