N
N
nkorobkov2018-10-04 01:36:11
Arduino
nkorobkov, 2018-10-04 01:36:11

How to make the diodes in the matrix not go out?

There is the following scheme:
5bb543e6be21a490202970.png
Code:

int valX = 0;
int valY = 0;
int fila = 5;
int columna = 13;
int lectura = 0;
int posX = constrain(posX, 0, 5);
int posY = constrain(posY,0,5);
int contX=constrain(contX, 0, 150);
int contY=constrain(contY, 0, 150);
int frame[6][6]=

 {
    {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,0}
};


void setup()
{
  for(int i=0; i<6; i++){
    pinMode(i, OUTPUT);
  }
  for(int i=8; i<14; i++){
    pinMode(i, OUTPUT);
  }
  	pinMode(6, INPUT);
  	pinMode(7, INPUT);
}

void limpiar(){
  for(int i=0; i<6; i++){
    digitalWrite(i, LOW);
  }
  for(int i=8; i<14; i++){
    digitalWrite(i, HIGH);
  }
}


void loop()
{
  valX = map(analogRead(5),0,1023,0,6);
  valY = map(analogRead(4),0,1023,0,6);
  
  switch(valX){
    case 1: if(contX>=100){
      				frame[posY][posX]=0;
      				posX--;
      				frame[posY][posX]=1;
      				contX=0;
    			}
    case 2: if(contX>=100){
      				frame[posY][posX]=0;
      				posX--;
      				frame[posY][posX]=1;
      				contX=0;
    			}
 				break;   	
    case 5: if(contX>=100){
      			frame[posY][posX]=0;
      			posX++;
      			frame[posY][posX]=1;
      			contX=0;
    		}
    			break;
    case 6: if(contX>=100){
      			frame[posY][posX]=0;
      			posX++;
      			frame[posY][posX]=1;
      			contX=0;
    		}
    			break;
  }
  
  switch(valY){
    case 1: if(contY>=100){
      				frame[posY][posX]=0;
      				posY--;
      				frame[posY][posX]=1;
      				contY=0;
    			}
 				break; 
    case 2: if(contY>=100){
      				frame[posY][posX]=0;
      				posY--;
      				frame[posY][posX]=1;
      				contY=0;
    			}
 				break; 
    case 4: if(contY>=100){
      			frame[posY][posX]=0;
      			posY++;
      			frame[posY][posX]=1;
      			contY=0;
    		}
    			break;
     
    case 5: if(contY>=100){
      			frame[posY][posX]=0;
      			posY++;
      			frame[posY][posX]=1;
      			contY=0;
    		}
    			break;
  }
  
  
  for(int scan=0; scan<1; scan++){
    for(int i=0; i<6; i++){
      digitalWrite(fila-i,HIGH);
      for(int j=0; j<6; j++){
        if(frame[i][j]==1){
          digitalWrite(columna-j, LOW);
        }
      }
      limpiar();
    }
  }
  contX++;
  contY++;
}

It is necessary to make sure that the diodes light up in turn, but after that they do not go out. That is, the sequential filling of the entire matrix from bottom to top, from right to left. Please help solve this problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dennzo, 2018-10-05
@dennzo

without looking at the code, but simply at the diagram and the task - but as described in the technical specification, strictly speaking, in general - is it possible?
("so that it does not go out" spoils everything somewhat, it is necessary to clarify - "so that it seems that it does not go out"?)
imagine a circuit without a duina, just with toggle switches, on rows and columns. IMHO, it doesn't work.
let's say they gave it to the bottom line, now we went to give it one by one, to the columns - for now, ok, the bottom row is filled in as you wanted, but then - row 2 - we give it to the second line, and we have two full lines on fire ... not one at a time is filled again, and the whole line at once, and then 3,4,5 in the same way ...
Or you need a dynamic display - like on 7 segment indicators, which are many in parallel,
but the matrices are scanned giving a symbol for the position to the common bus, and including the common cathode only for the required matrix.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question