Herramientas de usuario

Herramientas del sitio


proyectos:talleres:ets

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anteriorRevisión previa
Próxima revisión
Revisión previa
proyectos:talleres:ets [2023/10/02 00:22] – [El taller] brolinproyectos:talleres:ets [2023/10/03 13:50] (actual) – [Ejemplo básico] elmago116
Línea 96: Línea 96:
 <file c++ ejemplo.ino> <file c++ ejemplo.ino>
  
 +// Configurar - sujeto
 #include <FastLED.h> #include <FastLED.h>
 #define LED_PIN D3 #define LED_PIN D3
Línea 105: Línea 105:
 #define rojo CRGB::Red #define rojo CRGB::Red
 #define azul CRGB::Blue #define azul CRGB::Blue
-#define maplv1 0x00FF00 +#define colornuevo 0x00FF00
-#define maplv2 0x00AA00 +
-#define maplv3 0xFFFF00 +
-#define maplv4 0xFFE994 +
-#define maplv5 0xFFAA00 +
-#define maplv6 0xEC9BA4 +
-#define maplv7 0xE1AA00 +
-#define maplv8 0xFF00FF +
-#define maplv9 0x00DAFE +
-#define maplv10 0x0181FE+
  
 const uint8_t matrixWidth  = 8; const uint8_t matrixWidth  = 8;
Línea 126: Línea 117:
 const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz) const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
 unsigned int sample; unsigned int sample;
-  
-void setup() { 
-  Serial.begin(115200); 
-  LEDS.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds,NUM_LEDS); 
-  FastLED.setBrightness(BRIGHTNESS); 
-} 
    
 #define ESCENAS 1 #define ESCENAS 1
Línea 146: Línea 131:
   },   },
 }; };
- + 
 +void setup() { 
 +  Serial.begin(115200); 
 +  LEDS.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds,NUM_LEDS); 
 +  FastLED.setBrightness(BRIGHTNESS); 
 +
 + 
 +// Ejecutar en loop - predicado
 void loop() { void loop() {
-  for(int i = 0; i< matrixHeight; i++) { + 
-    for(int j = 0; j< matrixWidth; j++) { +  // Captura muestras de sonido
-      leds[i*matrixWidth + j] = matrix[loop_cnt%ESCENAS][i][j]; +
-    } +
-  }+
   unsigned long startMillis = millis();  // Start of sample window   unsigned long startMillis = millis();  // Start of sample window
   unsigned int peakToPeak = 0;   unsigned int peakToPeak = 0;
Línea 176: Línea 165:
    }    }
    peakToPeak = signalMax - signalMin;    peakToPeak = signalMax - signalMin;
 +   
 +   // Cambia brillo según segun nivel de sonido
    int changeBrightness = map(peakToPeak, 20, 500, 0, 100);    int changeBrightness = map(peakToPeak, 20, 500, 0, 100);
    FastLED.setBrightness(changeBrightness);    FastLED.setBrightness(changeBrightness);
 +    
 +  // Pinta la matriz de leds
 +  for(int i = 0; i< matrixHeight; i++) {
 +    for(int j = 0; j< matrixWidth; j++) {
 +      leds[i*matrixWidth + j] = matrix[loop_cnt%ESCENAS][i][j];
 +    }
 +  }
 +  
    FastLED.show();    FastLED.show();
    Serial.println(peakToPeak);    Serial.println(peakToPeak);
proyectos/talleres/ets.1696206175.txt.gz · Última modificación: 2023/10/02 00:22 por brolin