// FUNCION AUX. MATRIZ DE LEDS// void mostrarMatrizLeds(LedControl lc , char *status, int pausa) // FUNCIÓN FINAL QUE CONTROLA LA MATRIZ DE LEDS { // Paso los valores que recibo del Master en char a int tomate=letraAnumero(status[0]); nivelTomate=letraAnumero(status[1]); lechuga=letraAnumero(status[2]); nivelLechuga=letraAnumero(status[3]); marmol=letraAnumero(status[4]); nivelMarmol=letraAnumero(status[5]); camion=letraAnumero(status[6]); cortijo=letraAnumero(status[7]); // Ilumino la matriz de leds lc.clearDisplay(0); // Apago la columna 0 = contadorTomate contador(lc,0,tomate); // Enciendo en la columna 0 el numero de tomates que tengo pa' los gazpachoh contador(lc,1,nivelTomate); // Enciendo en la columna 1 el numero de nivelTomate que tengo contador(lc,2,lechuga); // Enciendo " " " 2 " " " lechugas " " contador(lc,3,nivelLechuga);// Enciendo " " " 3 " " " nivelLechugas " " que me lah quitan de la manoh contador(lc,4,marmol); // Enciendo " " " 4 " " " marmoles " " duros como ninguno! contador(lc,5,nivelMarmol); // Enciendo " " " 5 " " " nivelMarmoles " " contador(lc,6,camion); // Enciendo " " " 6 " " " fragonetas " " pa' robah contador(lc,7,cortijo); // Enciendo " " " 7 " " " cortijos " " pa' ser el mas riiico, ay papa! delay(pausa); lc.clearDisplay(0); // Apago la columna 0 = contadorTomate }
void loop() { int digit = counter; int dig1 = digit % 10; digit /= 10; int dig2 = digit % 10; digit /= 10; int dig3 = digit % 10; digit /= 10; int dig4 = digit % 10; digit /= 10; int dig5 = digit % 10; lc.clearDisplay(0); //lc.setDigit(0,7,0,false); //lc.setDigit(0,6,0,false); //lc.setDigit(0,5,0,false); lc.setDigit(0,4,dig5,false); lc.setDigit(0,3,dig4,false); lc.setDigit(0,2,dig3,false); lc.setDigit(0,1,dig2,false); lc.setDigit(0,0,dig1,false); // up if(state == 0) { if(counter > 0) { counter --; } else { pos=100; myservo.attach(servopin); myservo.write(160); delay(200); myservo.write(140); delay(200); myservo.write(120); delay(200); myservo.write(pos); delay(200); myservo.detach(); state = 1; counter = low; } // down } else if(state ==1) { if(counter > 0) { counter --; } else { pos=180; myservo.attach(servopin); myservo.write(pos); delay(500); myservo.detach(); state = 0; counter = high; } } delay(delaytime); }
void setup() { lc.shutdown(0,false); lc.setIntensity(1,80); lc.clearDisplay(0); myservo.write(180); myservo.attach(servopin); }
LedControl initMatrizLeds(){ LedControl lc = LedControl(DIN,CLK,CS,NUM_MATRIX); lc.shutdown(0,false);// turn off power saving, enables display lc.setIntensity(0,1);// sets brightness (0~15 possible values) lc.clearDisplay(0);// clear screen return lc; }
/* This time we have more than one device. But all of them have to be initialized individually. */ void setup() { lc=LedControl(12,11,10,1); /* The MAX72XX is in power-saving mode on startup, we have to do a wakeup call */ lc.shutdown(0,false); /* Set the brightness to a medium values */ lc.setIntensity(0,8); /* and clear the display */ lc.clearDisplay(0); }