buenas tardes
quisiera hacer que con dos pulsadores independientes se pueda escoger una otra rutina de visualización de dos diferentes matrices de led donde se visualizara lo programado en la rutina.
#include "LedControlMS.h"
//Proyecto de las luces direcionales para bici-usuarios
int val = 0; //val se emplea para almacenar el estado del boton
int state = 0; // 0 LED apagado, mientras que 1 encendido
int val1 = 0; //val1 se emplea para almacenar el estado del boton1
int state1 = 0; // 0 LED apagado, mientras que 1 encendido
int old_val = 0; // almacena el antiguo valor de val
int old_val1 = 0; // almacena el antiguo valor de val1
LedControl lc=LedControl(12,11,10,1);
LedControl lc1=LedControl(7,6,5,1);
unsigned long delaytime=500;
void setup() {
lc.shutdown(0,false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
lc1.shutdown(0,false);
lc1.setIntensity(0,8);
lc1.clearDisplay(0);
pinMode(3,INPUT); // y BOTON como señal de entrada
pinMode(2,INPUT); // y BOTON como señal de entrada
}
/*
This method will display the characters for the
word "Arduino" one after the other on the matrix.
(you need at least 5x7 leds to see the whole chars)
*/
void writeArduinoOnMatrix() {
/* here is the data for the characters */
byte a[8]={B00001000,B11111100,B11111110,B11111111,B11111110,B11111100,B00001000,B00000000};
/* now display them one by one with a small delay */
lc.setRow(0,0,a[0]);
lc.setRow(0,1,a[1]);
lc.setRow(0,2,a[2]);
lc.setRow(0,3,a[3]);
lc.setRow(0,4,a[4]);
lc.setRow(0,5,a[5]);
lc.setRow(0,6,a[6]);
lc.setRow(0,7,a[7]);
delay(delaytime);
// lc.setRow(0,0,0);
// lc.setRow(0,1,0);
// lc.setRow(0,2,0);
// lc.setRow(0,3,0);
// lc.setRow(0,4,0);
// lc.setRow(0,5,0);
// lc.setRow(0,6,0);
// lc.setRow(0,7,0);
// delay(delaytime);//fin de la primera matriz
}
void writeArduinoOnMatrix1() {
/* here is the data for the characters */
byte a[8]={B00001000,B11111100,B11111110,B11111111,B11111110,B11111100,B00001000,B00000000};
/* now display them one by one with a small delay */
lc1.setRow(0,0,a[0]);
lc1.setRow(0,1,a[1]);
lc1.setRow(0,2,a[2]);
lc1.setRow(0,3,a[3]);
lc1.setRow(0,4,a[4]);
lc1.setRow(0,5,a[5]);
lc1.setRow(0,6,a[6]);
lc1.setRow(0,7,a[7]);
delay(delaytime);
// lc1.setRow(0,0,0);
// lc1.setRow(0,1,0);
// lc1.setRow(0,2,0);
// lc1.setRow(0,3,0);
// lc1.setRow(0,4,0);
// lc1.setRow(0,5,0);
// lc1.setRow(0,6,0);
// lc1.setRow(0,7,0);
// delay(delaytime);
}
void BOTON() {
val= digitalRead(3); // lee el estado del Boton
if ((val == HIGH) && (old_val == LOW)){
state=1-state;
delay(10);
}
old_val = val; // valor del antiguo estado
if (state==1){
digitalWrite(writeArduinoOnMatrix,HIGH); // enciende el LED
}
else{
digitalWrite(writeArduinoOnMatrix,LOW);// apagar el LED
}
}
void BOTON1() {
val1= digitalRead(2); // lee el estado del Boton1
if ((val1 == HIGH) && (old_val1 == LOW)){
state1=1-state1;
delay(10);
}
old_val1 = val1; // valor del antiguo estado
if (state1==1){
digitalWrite(writeArduinoOnMatrix1,HIGH); // enciende el LED1
}
else{
digitalWrite(writeArduinoOnMatrix1,LOW); // apagar el LED1
}
}
void loop(){
writeArduinoOnMatrix();
writeArduinoOnMatrix1();
BOTON();
BOTON1();
}
tengo este codigo pero no hace lo que se quiere me pueden colaborar