Pages: [1]   Go Down
Author Topic: Receiving junk info from serial monitor  (Read 1260 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm just starting out with arduino. Right now im trying to get an arduino Mega clone to print out the values contained in an 8x8 bidimentional array. everything seems to be working out just fine, but instead of printing the information, the only thing I can see i a series of junk info formatted as I have specified in my code (8 characters, newline, 8 characters, and so on) what could I be getting wrong?

I'm using an arduino mega clone with arduino IDE0022 under windows xp.

Code:
int valor; //para mostrar el punto de la matriz
int x; //para recorrer filas
int y; //para recorrer columnas

//nuestro matriz
byte tablilla[8][8]={
  {0,0,0,0,0,0,0,0},
  {0,1,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,0,0},
  {0,0,0,0,0,0,0,0},
  {0,0,0,0,0,0,0,0}
                  
};
void setup() {

 //comenzamos con el puerto serial
 Serial.begin(9600);
}

void loop() {
  
  for(y=0;y<8;y++){  //columnas
  Serial.println(); //una columna nueva
    
    for(x=0;x<8;x++){  //filas
      valor=tablilla[x][y]; //guardamos todo en una variable
      Serial.write(tablilla[x][y]);  //mostramos ese valor
    }
  }
 
 //limpiamos la pantalla
 Serial.print(27,BYTE);   //tecla "esc"
 Serial.print("[2J");   //clrs
}
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 5
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try:

Serial.write(tablilla
  • [y],DEC);
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks, actually i switched to using

Code:
Serial.print(tablilla[x][y]);

My error was in thinking that the "Serial.write()" was used to send just one character, it does, but it sends it in binary form. I'm much better off using the "Serial.print()"
Logged

Pages: [1]   Go Up
Jump to: