Esempio n. 1
0
// 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

  }
Esempio n. 2
0
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);
}
Esempio n. 3
0
void setup() {

  lc.shutdown(0,false);
  lc.setIntensity(1,80);
  lc.clearDisplay(0);
  myservo.write(180);
  myservo.attach(servopin);
}
Esempio n. 4
0
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;
}
Esempio n. 5
0
/*
  This function lights up a some Leds in a column.
 The pattern will be repeated on every column.
 The pattern will blink along with the column-number.
 column number 4 (index==3) will blink 4 times etc.
 */
void columns() {
  for(int col=0;col<8;col++) {
    delay(100);
    lc.setColumn(0,col,0b10100000);
    delay(100);
    lc.setColumn(0,col,(byte)0);
    for(int i=0;i<col;i++) {
      delay(100);
      lc.setColumn(0,col,0b10100000);
      delay(100);
      lc.setColumn(0,col,(byte)0);
    }
  }
}
Esempio n. 6
0
/*
  This function lights up a some Leds in a row.
 The pattern will be repeated on every row.
 The pattern will blink along with the row-number.
 row number 4 (index==3) will blink 4 times etc.
 */
void rows() {
  for(int row=0;row<8;row++) {
    delay(100);
    lc.setRow(0,row,0b10100000);
    delay(100);
    lc.setRow(0,row,(byte)0);
    for(int i=0;i<row;i++) {
      delay(100);
      lc.setRow(0,row,0b10100000);
      delay(100);
      lc.setRow(0,row,(byte)0);
    }
  }
}
Esempio n. 7
0
/*
 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);
}
Esempio n. 8
0
/*
 This function will light up every Led on the matrix.
 The led will blink along with the row-number.
 row number 4 (index==3) will blink 4 times etc.
 */
void single() {
  for(int row=0;row<8;row++) {
    for(int col=0;col<8;col++) {
      delay(100);
      lc.setLed(0,row,col,true);
      delay(100);
      for(int i=0;i<col;i++) {
        lc.setLed(0,row,col,false);
        delay(100);
        lc.setLed(0,row,col,true);
        delay(100);
      }
    }
  }
}
Esempio n. 9
0
int contador (LedControl lc, int parametro, int unidad)  // enciende en el contador (columna) el numero de leds (niveles) de cada contador
  {
    for ( led=0; led<unidad; led++)
     { 
      lc.setLed(0,parametro,led,true);
     } 
  }
Esempio n. 10
0
void encenderTodo(LedControl lc){
  
  for ( led=0; led<8; led++)
    {  
      for ( columna=0; columna<8; columna++)
      {
        lc.setLed(0,columna,led,true);
      }
    }
}
Esempio n. 11
0
void apagarTodo(LedControl lc){
  
  for ( led=0; led<8; led++)
    {  
      for ( columna=0; columna<8; columna++)
      {
        lc.setLed(0,columna,led,false);
      }
    }
  
}
Esempio n. 12
0
void loop()
{
	// Some tests...
	//rows();
	//columns();
	//single();

	// Alphabet
	for (int ascii=0; ascii<41; ascii++)
	{
		//lc.clearDisplay(0);
		lc.displayChar(0,ascii);
		delay(delaytime);
	}
  delay(1000);
}