Hola a todos tengo un problema con mi codigo, estoy tratando de hacer un marcador de juego pero no puedo hacer que funcione, tengo problema en los for´s y en el printStringWithShift(); el cual no se si este escrito correctamente.
Hice un array con 9 numeros enteros para hacer el codigo mas facil y uso el array en el for para mostrar en la matirz de leds la posicion del array pero no me sale me pone error en el .lenght de mi for .
Hello everybody I have a problem with my code, I'm trying to make a scoreboard but I can make it work, I have a problem in my for's and in printStringWithShift (); which I do not know if it is written correctly.
I create 2 arrays for 9 goals for make the code more simply but if you have another opcion I would appreciate so much.
#include "MaxMatrix.h"
#include <avr/pgmspace.h>
PROGMEM prog_uchar CH[] = {
erase all characters because exceeds 9000 characters to post this. but here are a to z and 1 to 9 and special characters.
};
int data = 12; // DIN pin of MAX7219 module
int load = 10; // CS pin of MAX7219 module
int cloc= 11; // CLK pin of MAX7219 module
int maxInUse = 1; //change this variable to set how many MAX7219's you'll use
[color=#ff0000]//Code that I modified- Desde aqui empiezo a modificar //[/color]
int equipo;
int cont = 0;
MaxMatrix m(data, load, cloc, maxInUse); // define module
byte buffer[10];
char string1[] = " 0 - 0";
int string2[] = {1,2,3,4,5,6,7,8,9};
int string3[] = {1,2,3,4,5,6,7,8,9};
int contador1 = 0;
int contador2 = 0;
void setup(){
m.init(); // module initialize
m.setIntensity(0); // dot matix intensity 0-15
Serial.begin(9600); // serial communication initialize
}
void loop(){
int i;
printStringWithShift(string1, 390);
for(int i=0;i>0;i++){
Serial.println("Que equipo anoto Gol?"); //"What team make a goal?"
delay(5000);
int equipo = Serial.parseInt();
if(equipo = 1){
for( int x=0; x<= string2.length(); x++){ [color=#ff0000]//One error in .length//[/color]
Serial.println("Chivas anoto 1 gol, llevan " string2[x] " goles anotados.")0; //"Team chivas make 1 goal they have" string[x] " goals".
int x++;
}
contador1 = contador1 + 1;
}else{
for(int x=0; x<= equipo2.length(); x++){
Serial.println(" Cruz Azul anoto 1 gol, llevan " equipo2[n] " goles anotados"); //"Team Cruz Azul make 1 goal they have" string[x] " goals".
int x++;
}
contador2 = contador2 +1;
}
printStringWithShift(contador1, "-", contador2, 390); [color=#ff0000]//Here I dont know how to put like 1 - 1 in the led 8x8 like int a + char "-" + int b //[/color]
int i++;
}
}
[color=#ff0000]/end of code modify/[/color]
void printCharWithShift(char c, int shift_speed){
if (c < 32) return;
c -= 32;
memcpy_P(buffer, CH + 7*c, 7);
m.writeSprite(32, 0, buffer);
m.setColumn(32 + buffer[0], 0);
for (int i=0; i<buffer[0]+1; i++)
{
delay(shift_speed);
m.shiftLeft(false, false);
}
}
void printStringWithShift(char* s, int shift_speed){
while (*s != 0){
printCharWithShift(*s, shift_speed);
s++;
}
}
void printString(char* s)
{
int col = 0;
while (*s != 0)
{
if (*s < 32) continue;
char c = *s - 32;
memcpy_P(buffer, CH + 7*c, 7);
m.writeSprite(col, 0, buffer);
m.setColumn(col + buffer[0], 0);
col += buffer[0] + 1;
s++;
}
}