Hello friends!
I cannot output data via I2C from more than 4 cameras, can you tell me where to fix it?
I don’t understand where in “Pixy2I2C.h” to change
#define I2C
#ifdef I2C
#include <Pixy2I2C.h>
#include <Wire.h>
Pixy2I2C pixy;
Pixy2I2C pixy1;
Pixy2I2C pixy2;
Pixy2I2C pixy3;
Pixy2I2C pixy4;
Pixy2I2C pixy5;
Pixy2I2C pixy6;
Pixy2I2C pixy7;
Pixy2I2C pixy8;
#else
#endif
//int i;
int o;
int r;
int b;
int g;
int c;
void setup() {
Serial.begin(115200);
Serial.print("\n");
Wire.begin();
pixy.init(0x30);
pixy1.init(0x31);
pixy2.init(0x32);
pixy3.init(0x33);
pixy4.init(0x34);
pixy5.init(0x35);
pixy6.init(0x36);
pixy7.init(0x37);
pixy8.init(0x38);
}
void loop() {
readOne();
readTwo();
readThree();
readFour();
readFive();
readSix();
readSeven();
readEight();
readNine();
}
void readOne()
{
int numBlocks = pixy.ccc.getBlocks();
if (numBlocks)
{
int i;
o = 0;
r = 0;
b = 0;
g = 0;
for (i = 0; i < numBlocks; i++)
{
int signature = pixy.ccc.blocks[i].m_signature;
if (signature == 1)
{
o == o++;
}
else if (signature == 2)
{
r == r++;
}
else if (signature == 3)
{
b == b++;
}
else if (signature == 4)
{
g == g++;
}
}
if (i >= numBlocks)
// Serial.print("| ");
Serial.print("C: ");
Serial.print("30");
Serial.print(" O: ");
Serial.print(o);
Serial.print(" R: ");
Serial.print(r);
Serial.print(" B: ");
Serial.print(b);
Serial.print(" G: ");
Serial.print(g);
Serial.print(" A: ");
Serial.print(pixy.ccc.numBlocks);
// Serial.print(" | ");
Serial.print("\t");
}
else
{
o = -1;
r = -1;
b = -1;
g = -1;
// Serial.print("| ");
Serial.print("C: ");
Serial.print("30");
Serial.print(" O: " );
Serial.print(o);
Serial.print(" R: ");
Serial.print(r);
Serial.print(" B: ");
Serial.print(b);
Serial.print(" G: ");
Serial.print(g);
Serial.print(" A: ");
Serial.print(pixy.ccc.numBlocks);
// Serial.print(" | ");
Serial.print("\t");
}
}
void readTwo()
{
int numBlocks = pixy1.ccc.getBlocks();
if (numBlocks)
{
int i;
o = 0;
r = 0;
b = 0;
g = 0;
for (i = 0; i < numBlocks; i++)
{
int signature = pixy1.ccc.blocks[i].m_signature;
if (signature == 1)
{
o == o++;
}
else if (signature == 2)
{
r == r++;
}
else if (signature == 3)
{
b == b++;
}
else if (signature == 4)
{
g == g++;
}
}
if (i >= numBlocks)
Serial.print("C: ");
Serial.print("31");
Serial.print(" O: ");
Serial.print(o);
Serial.print(" R: ");
Serial.print(r);
Serial.print(" B: ");
Serial.print(b);
Serial.print(" G: " );
Serial.print(g);
Serial.print(" A: ");
Serial.print(pixy1.ccc.numBlocks);
// Serial.print(" | ");
// Serial.println(" | ");
Serial.print("\t");
}
else
{
o = -1;
r = -1;
b = -1;
g = -1;
Serial.print("C: ");
Serial.print("31");
Serial.print(" O: ");
Serial.print(o);
Serial.print(" R: ");
Serial.print(r);
Serial.print(" B: ");
Serial.print(b);
Serial.print(" G: ");
Serial.print(g);
Serial.print(" A: ");
Serial.print(pixy1.ccc.numBlocks);
// Serial.print(" | ");
// Serial.println(" | ");
Serial.print("\t");
}
}
void readThree()
{
int numBlocks = pixy2.ccc.getBlocks();
if (numBlocks)
{
int i;
o = 0;
r = 0;
b = 0;
g = 0;
for (i = 0; i < numBlocks; i++)
{
int signature = pixy2.ccc.blocks[i].m_signature;
if (signature == 1)
{
o == o++;
}
else if (signature == 2)
{
r == r++;
}
else if (signature == 3)
{
b == b++;
}
else if (signature == 4)
{
g == g++;
}
}
if (i >= numBlocks)
Serial.print("cam3:32");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy2.ccc.numBlocks);
Serial.print(" | ");
}
else
{
o = -1;
r = -1;
b = -1;
g = -1;
Serial.print("cam3:32");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy2.ccc.numBlocks);
Serial.print(" | ");
}
}
void readFour()
{
int numBlocks = pixy3.ccc.getBlocks();
if (numBlocks)
{
int i;
o = 0;
r = 0;
b = 0;
g = 0;
for (i = 0; i < numBlocks; i++)
{
int signature = pixy3.ccc.blocks[i].m_signature;
if (signature == 1)
{
o == o++;
}
else if (signature == 2)
{
r == r++;
}
else if (signature == 3)
{
b == b++;
}
else if (signature == 4)
{
g == g++;
}
}
if (i >= numBlocks)
Serial.print("cam4:33");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy3.ccc.numBlocks);
Serial.print(" | ");
}
else
{
o = -1;
r = -1;
b = -1;
g = -1;
Serial.print("cam4:33");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy3.ccc.numBlocks);
Serial.print(" | ");
}
}
void readFive()
{
int numBlocks = pixy4.ccc.getBlocks();
if (numBlocks)
{
int i;
o = 0;
r = 0;
b = 0;
g = 0;
for (i = 0; i < numBlocks; i++)
{
int signature = pixy4.ccc.blocks[i].m_signature;
if (signature == 1)
{
o == o++;
}
else if (signature == 2)
{
r == r++;
}
else if (signature == 3)
{
b == b++;
}
else if (signature == 4)
{
g == g++;
}
}
if (i >= numBlocks)
Serial.print("cam5:34");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy4.ccc.numBlocks);
Serial.print(" | ");
}
else
{
o = -1;
r = -1;
b = -1;
g = -1;
Serial.print("cam5:34");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy4.ccc.numBlocks);
Serial.print(" | ");
}
}
void readSix()
{
int numBlocks = pixy5.ccc.getBlocks();
if (numBlocks)
{
int i;
o = 0;
r = 0;
b = 0;
g = 0;
for (i = 0; i < numBlocks; i++)
{
int signature = pixy5.ccc.blocks[i].m_signature;
if (signature == 1)
{
o == o++;
}
else if (signature == 2)
{
r == r++;
}
else if (signature == 3)
{
b == b++;
}
else if (signature == 4)
{
g == g++;
}
}
if (i >= numBlocks)
Serial.print("cam6:35");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy5.ccc.numBlocks);
Serial.print(" | ");
}
else
{
o = -1;
r = -1;
b = -1;
g = -1;
Serial.print("cam6:35");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy5.ccc.numBlocks);
Serial.print(" | ");
}
}
void readSeven()
{
int numBlocks = pixy6.ccc.getBlocks();
if (numBlocks)
{
int i;
o = 0;
r = 0;
b = 0;
g = 0;
for (i = 0; i < numBlocks; i++)
{
int signature = pixy6.ccc.blocks[i].m_signature;
if (signature == 1)
{
o == o++;
}
else if (signature == 2)
{
r == r++;
}
else if (signature == 3)
{
b == b++;
}
else if (signature == 4)
{
g == g++;
}
}
if (i >= numBlocks)
Serial.print("cam7:36");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy6.ccc.numBlocks);
Serial.print(" | ");
}
else
{
o = -1;
r = -1;
b = -1;
g = -1;
Serial.print("cam7:36");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy6.ccc.numBlocks);
Serial.print(" | ");
}
}
void readEight()
{
int numBlocks = pixy7.ccc.getBlocks();
if (numBlocks)
{
int i;
o = 0;
r = 0;
b = 0;
g = 0;
for (i = 0; i < numBlocks; i++)
{
int signature = pixy7.ccc.blocks[i].m_signature;
if (signature == 1)
{
o == o++;
}
else if (signature == 2)
{
r == r++;
}
else if (signature == 3)
{
b == b++;
}
else if (signature == 4)
{
g == g++;
}
}
if (i >= numBlocks)
Serial.print("cam8:37");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy7.ccc.numBlocks);
Serial.print(" | ");
}
else
{
o = -1;
r = -1;
b = -1;
g = -1;
Serial.print("cam8:37");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy7.ccc.numBlocks);
Serial.print(" | ");
}
}
void readNine()
{
int numBlocks = pixy8.ccc.getBlocks();
if (numBlocks)
{
int i;
o = 0;
r = 0;
b = 0;
g = 0;
for (i = 0; i < numBlocks; i++)
{
int signature = pixy8.ccc.blocks[i].m_signature;
if (signature == 1)
{
o == o++;
}
else if (signature == 2)
{
r == r++;
}
else if (signature == 3)
{
b == b++;
}
else if (signature == 4)
{
g == g++;
}
}
if (i >= numBlocks)
Serial.print("cam9:38");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy8.ccc.numBlocks);
Serial.println(" | ");
}
else
{
o = -1;
r = -1;
b = -1;
g = -1;
Serial.print("cam9:38");
Serial.print(" o:");
Serial.print(o);
Serial.print(" r:");
Serial.print(r);
Serial.print(" b:");
Serial.print(b);
Serial.print(" g:");
Serial.print(g);
Serial.print(" all:");
Serial.print(pixy8.ccc.numBlocks);
Serial.println(" | ");
}
}