We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I just got this little 8x8 LED matrix for my arduino and i wanted to make a program on the computer in wich i can draw and then export it to my arduino. Now i am writing this program, I got all the little circles drawn and stored in an array but I want when my mouse is hovering over them to light up. This works great but it just does not interact with the last collumn of the board. And I can't seem to solve it, another thing is i can't get it to work to check for the y values, now it only checks for the x values.
int pixelCount = 64;
int xpos = 0;
int ypos = 0;
float [] pixelSize = new float[pixelCount];
float [] xPos = new float[pixelCount];
float [] yPos = new float[pixelCount];
void setup() {
size(400, 400); // size always goes first!
if (frame != null) {
frame.setResizable(true);
}
for (int i=0; i<pixelCount; i++) {
pixelSize[i] = 50;
xPos[i] = xpos+25;
xpos += 50;
yPos[i] = ypos+25;
if(xpos == 400) {
xpos = 0;
ypos += 50;
}
}
}
void draw() {
background(255);
for(int i=0; i<pixelCount; i++){
smooth();
fill(255,255,255,255);
//noStroke();
ellipse(xPos[i],yPos[i],50,50);
}
for(int z = 0; z < 63; z++) {
if(mouseX > xPos[z]-25 && mouseX < xPos[z+1]-25) {
// if (80 > yPos[z] && 80 < yPos[z+1]){
fill(255,0,0,255);
ellipse(xPos[z],yPos[z],50,50);
print(mouseX);
//}
}
}
}
Answers
for(int z = 0; z < 63; z++) {
do you mean < 63?
well, if i do <64 i get an overflow EDIT: got it, adding 1 to the array when it was on its limit was the problem.