I am working on Image processing program that will divide certain columns with other columns.
Check out my sample code & its results!
The problem is that, I run this code on both arduino Mega & DUE.
Arduino Mega give the correct division while DUE fails & shows only zeros.
I don’t know why Arduino DUE isn’t dividing properly, I have tried many other mathematical equations but Arduino DUE don’t work properly. Please help me out!
Beside mathematical calculations, Arduino Due works finely!
P.S Both arduinos are healthy
My code:
int narray[5][7];
void setup() {
Serial.begin(9600);
}
void loop() {
int h[5][28] = {{0, 0, 0, 255, 0, 0, 0,0, 0, 0, 255, 0, 0, 0,0, 0, 0, 255, 0, 0, 0,0, 0, 0, 255, 0, 0, 0},
{0, 255, 255, 255, 255, 255, 0,0, 255, 255, 255, 255, 255, 0,0, 255, 255, 255, 255, 255, 0,0, 255, 255, 255, 255, 255, 0},
{0, 255, 0, 255, 0, 0, 0,0, 255, 0, 255, 0, 0, 0,0, 255, 0, 255, 0, 0, 0,0, 255, 0, 255, 0, 0, 0},
{0, 255, 255, 0, 255, 255, 0,0, 255, 255, 0, 255, 255, 0,0, 255, 255, 0, 255, 255, 0,0, 255, 255, 0, 255, 255, 0},
{0, 255, 255, 255, 255, 255, 0,0, 255, 255, 255, 255, 255, 0,0, 255, 255, 255, 255, 255, 0,0, 255, 255, 255, 255, 255, 0}, };
int k=0;
for( int f=0; f<5; f++)
{
for(int e=0; e<21; e++)
{
h[f][k]=h[f][k]/h[f][e+7];
delay(50);
if(k==7)
{
k=0;
delay(50);
}
else k++;
}
}
for (int c=0; c<5;c++)
{
for(int d=0; d<7; d++)
{
narray[c][d]=h[c][d];
Serial.print(narray[c][d]); //send the byte to serial port is ok; show the byte in HEX format where u r receiving it
Serial.print("\t");
}
Serial.print("\n");
}
}
Arduino DUE results:
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Arduino Mega results
0 0 -1 1 -1 0 0
1 0 -1 0 -1 -1 -1
0 0 -1 1 -1 0 0
1 0 0 0 0 0 -1
0 0 0 0 0 -1 0