Tengo un Arduino Uno y estoy ejecutando un boceto con muchas variables (23 matrices de caracteres constantes que tienen 54 objetos en cada matriz). Junto con todas estas variables hay muchas declaraciones if. El proyecto controla una tira de neopixel LED RGB donde cada LED es independiente (basado en WS2812). Este código funciona bien debajo del Uno y los LED parpadean como se espera. Sin embargo, cuando puse el código en el ATtiny85, todos parpadean al azar o algunos se encienden y permanecen encendidos. El código compila y carga sin errores en el Attiny85. ¿No estoy seguro de qué está sucediendo y que no funcionará? Cualquier ayuda es muy apreciada!
Estoy definiendo los arreglos como const char arrayName[] =
y me preguntaba si ese es el problema porque hay tantos?
El código es para hacer un reloj de palabra LED RGB. La razón por la que me gustaría usar un Attiny es 1. Ya lo tengo (pero podría comprar otra cosa que no sea totalmente inaceptable). y 2. es lo suficientemente pequeño como para caber en el caso.
Podría comprar otro chip, pero me gustaría entender las limitaciones y por qué no funciona antes de comprar otro chip.
Si no es posible hacer que esto funcione en el Attiny85, ¿existe un pequeño chip alternativo que funcione?
A continuación se muestra el código, con la excepción de que en este momento está configurado para la impresión en serie en lugar de la salida real del LED RGB. ¿Hay alguna forma más eficiente de resolver el problema?
const char it[] = {'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'};
const char is[] = {'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'};
const char mten[] = {'0','0','1','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'};
const char half[] = {'0','0','0','0','1','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'};
const char twenty[] = {'0','0','0','0','0','0','1','1','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'};
const char quarter[] = {'0','0','0','0','0','0','0','0','0','1','1','1','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'};
const char mfive[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','1','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'};
const char minutes[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1','1','1','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'};
const char two[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1','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'};
const char one[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1','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'};
const char to[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','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'};
const char past[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1','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'};
const char three[] = {'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','1','1','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'};
const char four[] = {'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','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
const char five[] = {'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','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
const char eight[] = {'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','1','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
const char seven[] = {'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','1','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
const char six[] = {'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','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0'};
const char nine[] = {'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','1','1','0','0','0','0','0','0','0','0','0','0','0'};
const char ten[] = {'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','1','1','0','0','0','0','0','0','0','0','0'};
const char eleven[] = {'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','1','1','1','0','0','0','0','0','0'};
const char oclock[] = {'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','1','1','1','0','0','0'};
const char twelve[] = {'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','1','1','1'};
char pins[55] = {'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','const char it[] = {'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'};
const char is[] = {'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'};
const char mten[] = {'0','0','1','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'};
const char half[] = {'0','0','0','0','1','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'};
const char twenty[] = {'0','0','0','0','0','0','1','1','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'};
const char quarter[] = {'0','0','0','0','0','0','0','0','0','1','1','1','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'};
const char mfive[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','1','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'};
const char minutes[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1','1','1','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'};
const char two[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1','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'};
const char one[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1','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'};
const char to[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','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'};
const char past[] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1','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'};
const char three[] = {'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','1','1','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'};
const char four[] = {'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','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
const char five[] = {'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','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
const char eight[] = {'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','1','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
const char seven[] = {'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','1','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
const char six[] = {'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','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0'};
const char nine[] = {'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','1','1','0','0','0','0','0','0','0','0','0','0','0'};
const char ten[] = {'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','1','1','0','0','0','0','0','0','0','0','0'};
const char eleven[] = {'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','1','1','1','0','0','0','0','0','0'};
const char oclock[] = {'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','1','1','1','0','0','0'};
const char twelve[] = {'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','1','1','1'};
char pins[55] = {'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','%pre%'};
int red = 50;
int grn = 0;
int blu = 0;
uint8_t oldminute = 0;
void setup () {
}
void editPins(const char add[]) {
for (int a = 0; a < 54; a++) {
if (add[a] == '1') {
pins[a] = '1';
}
}
}
void loop () {
uint8_t hourvalue, minutevalue;
hourvalue = 8;
minutevalue = 13;
for (int x = 0; x < 55; x++) {
pins[x] = '0';
}
if ((minutevalue>4) && (minutevalue<10)) {
editPins(mfive);
editPins(minutes);
}
if ((minutevalue>9) && (minutevalue<15)) {
editPins(mten);
editPins(minutes);
}
if ((minutevalue>14) && (minutevalue<20)) {
editPins(quarter);
}
if ((minutevalue>19) && (minutevalue<25)) {
editPins(twenty);
editPins(minutes);
}
if ((minutevalue>24) && (minutevalue<30)) {
editPins(twenty);
editPins(mfive);
editPins(minutes);
}
if ((minutevalue>29) && (minutevalue<35)) {
editPins(half);
}
if ((minutevalue>34) && (minutevalue<40)) {
editPins(twenty);
editPins(mfive);
editPins(minutes);
}
if ((minutevalue>39) && (minutevalue<45)) {
editPins(twenty);
editPins(minutes);
}
if ((minutevalue>44) && (minutevalue<50)) {
editPins(quarter);
}
if ((minutevalue>49) && (minutevalue<55)) {
editPins(mten);
editPins(minutes);
}
if (minutevalue>54) {
editPins(mfive);
editPins(minutes);
}
if ((minutevalue <5)) {
if (hourvalue==1) {
editPins(one);
}
if (hourvalue==2) {
editPins(two);
}
if (hourvalue==3) {
editPins(three);
}
if (hourvalue==4) {
editPins(four);
}
if (hourvalue==5) {
editPins(five);
}
if (hourvalue==6) {
editPins(six);
}
if (hourvalue==7) {
editPins(seven);
}
if (hourvalue==8) {
editPins(eight);
}
if (hourvalue==9) {
editPins(nine);
}
if (hourvalue==10) {
editPins(ten);
}
if (hourvalue==11) {
editPins(eleven);
}
if (hourvalue==12) {
editPins(twelve);
}
editPins(oclock);
} else
if ((minutevalue < 35) && (minutevalue >4)) {
editPins(past);
if (hourvalue==1) {
editPins(one);
}
if (hourvalue==2) {
editPins(two);
}
if (hourvalue==3) {
editPins(three);
}
if (hourvalue==4) {
editPins(four);
}
if (hourvalue==5) {
editPins(five);
}
if (hourvalue==6) {
editPins(six);
}
if (hourvalue==7) {
editPins(seven);
}
if (hourvalue==8) {
editPins(eight);
}
if (hourvalue==9) {
editPins(nine);
}
if (hourvalue==10) {
editPins(ten);
}
if (hourvalue==11) {
editPins(eleven);
}
if (hourvalue==12) {
editPins(twelve);
}
} else {
// if we are greater than 34 minutes past the hour then display
// the next hour, as we will be displaying a 'to' sign
editPins(to);
if (hourvalue==1) {
editPins(two);
}
if (hourvalue==2) {
editPins(three);
}
if (hourvalue==3) {
editPins(four);
}
if (hourvalue==4) {
editPins(five);
}
if (hourvalue==5) {
editPins(six);
}
if (hourvalue==6) {
editPins(seven);
}
if (hourvalue==7) {
editPins(eight);
}
if (hourvalue==8) {
editPins(nine);
}
if (hourvalue==9) {
editPins(ten);
}
if (hourvalue==10) {
editPins(eleven);
}
if (hourvalue==11) {
editPins(twelve);
}
if (hourvalue==12) {
editPins(one);
}
}
for (int x = 0; x < 54; x++) {
if (pins[x]=='1') {
Serial.println(x);
}
}
delay(5000);
}
'};
int red = 50;
int grn = 0;
int blu = 0;
uint8_t oldminute = 0;
void setup () {
}
void editPins(const char add[]) {
for (int a = 0; a < 54; a++) {
if (add[a] == '1') {
pins[a] = '1';
}
}
}
void loop () {
uint8_t hourvalue, minutevalue;
hourvalue = 8;
minutevalue = 13;
for (int x = 0; x < 55; x++) {
pins[x] = '0';
}
if ((minutevalue>4) && (minutevalue<10)) {
editPins(mfive);
editPins(minutes);
}
if ((minutevalue>9) && (minutevalue<15)) {
editPins(mten);
editPins(minutes);
}
if ((minutevalue>14) && (minutevalue<20)) {
editPins(quarter);
}
if ((minutevalue>19) && (minutevalue<25)) {
editPins(twenty);
editPins(minutes);
}
if ((minutevalue>24) && (minutevalue<30)) {
editPins(twenty);
editPins(mfive);
editPins(minutes);
}
if ((minutevalue>29) && (minutevalue<35)) {
editPins(half);
}
if ((minutevalue>34) && (minutevalue<40)) {
editPins(twenty);
editPins(mfive);
editPins(minutes);
}
if ((minutevalue>39) && (minutevalue<45)) {
editPins(twenty);
editPins(minutes);
}
if ((minutevalue>44) && (minutevalue<50)) {
editPins(quarter);
}
if ((minutevalue>49) && (minutevalue<55)) {
editPins(mten);
editPins(minutes);
}
if (minutevalue>54) {
editPins(mfive);
editPins(minutes);
}
if ((minutevalue <5)) {
if (hourvalue==1) {
editPins(one);
}
if (hourvalue==2) {
editPins(two);
}
if (hourvalue==3) {
editPins(three);
}
if (hourvalue==4) {
editPins(four);
}
if (hourvalue==5) {
editPins(five);
}
if (hourvalue==6) {
editPins(six);
}
if (hourvalue==7) {
editPins(seven);
}
if (hourvalue==8) {
editPins(eight);
}
if (hourvalue==9) {
editPins(nine);
}
if (hourvalue==10) {
editPins(ten);
}
if (hourvalue==11) {
editPins(eleven);
}
if (hourvalue==12) {
editPins(twelve);
}
editPins(oclock);
} else
if ((minutevalue < 35) && (minutevalue >4)) {
editPins(past);
if (hourvalue==1) {
editPins(one);
}
if (hourvalue==2) {
editPins(two);
}
if (hourvalue==3) {
editPins(three);
}
if (hourvalue==4) {
editPins(four);
}
if (hourvalue==5) {
editPins(five);
}
if (hourvalue==6) {
editPins(six);
}
if (hourvalue==7) {
editPins(seven);
}
if (hourvalue==8) {
editPins(eight);
}
if (hourvalue==9) {
editPins(nine);
}
if (hourvalue==10) {
editPins(ten);
}
if (hourvalue==11) {
editPins(eleven);
}
if (hourvalue==12) {
editPins(twelve);
}
} else {
// if we are greater than 34 minutes past the hour then display
// the next hour, as we will be displaying a 'to' sign
editPins(to);
if (hourvalue==1) {
editPins(two);
}
if (hourvalue==2) {
editPins(three);
}
if (hourvalue==3) {
editPins(four);
}
if (hourvalue==4) {
editPins(five);
}
if (hourvalue==5) {
editPins(six);
}
if (hourvalue==6) {
editPins(seven);
}
if (hourvalue==7) {
editPins(eight);
}
if (hourvalue==8) {
editPins(nine);
}
if (hourvalue==9) {
editPins(ten);
}
if (hourvalue==10) {
editPins(eleven);
}
if (hourvalue==11) {
editPins(twelve);
}
if (hourvalue==12) {
editPins(one);
}
}
for (int x = 0; x < 54; x++) {
if (pins[x]=='1') {
Serial.println(x);
}
}
delay(5000);
}