proyectos:vestuario_aqa
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previa | |||
proyectos:vestuario_aqa [2021/05/18 00:18] – kz | proyectos:vestuario_aqa [2021/10/30 23:38] (actual) – kz | ||
---|---|---|---|
Línea 724: | Línea 724: | ||
matrix.show(); | matrix.show(); | ||
delay(100); | delay(100); | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== código para manipular con microfono la intensidad de la matriz de led ==== | ||
+ | |||
+ | <code c++> | ||
+ | |||
+ | #include < | ||
+ | #include < | ||
+ | #define LED_PIN | ||
+ | #define LED_TYPE | ||
+ | #define COLOR_ORDER GRB | ||
+ | #define f false | ||
+ | #define t true | ||
+ | |||
+ | const uint8_t kMatrixWidth | ||
+ | const uint8_t kMatrixHeight = 8; | ||
+ | #define NUM_LEDS (kMatrixWidth * kMatrixHeight) | ||
+ | |||
+ | int BRIGHTNESS = 60; // this is half brightness | ||
+ | CRGB leds[kMatrixWidth * kMatrixHeight]; | ||
+ | |||
+ | #define amarillo CRGB:: | ||
+ | #define black CRGB:: | ||
+ | #define rojo CRGB::Red | ||
+ | #define blue CRGB::Blue | ||
+ | |||
+ | int loop_cnt = 0; | ||
+ | |||
+ | const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz) | ||
+ | unsigned int sample; | ||
+ | |||
+ | uint8_t noise[kMatrixWidth][kMatrixHeight]; | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(115200); | ||
+ | LEDS.addLeds< | ||
+ | FastLED.setBrightness(BRIGHTNESS); | ||
+ | } | ||
+ | |||
+ | #define ESCENAS 1 | ||
+ | |||
+ | CRGB matrix[ESCENAS][8][8] = { | ||
+ | { | ||
+ | {blue, blue, blue,blue, blue, blue, blue,blue}, | ||
+ | {blue, blue, blue,blue, blue, blue, blue,blue}, | ||
+ | {blue, blue, blue,blue, blue, blue, blue,blue}, | ||
+ | {blue, blue, blue,blue, blue, blue, blue,blue}, | ||
+ | {blue, blue, blue,blue, blue, blue, blue,blue}, | ||
+ | {blue, blue, blue,blue, blue, blue, blue,blue}, | ||
+ | {blue, blue, blue,blue, blue, blue, blue,blue}, | ||
+ | {blue, blue, blue,blue, blue, blue, blue,blue}, | ||
+ | }, | ||
+ | }; | ||
+ | |||
+ | void loop() { | ||
+ | for(int i = 0; i< kMatrixHeight; | ||
+ | for(int j = 0; j< kMatrixWidth; | ||
+ | leds[i*kMatrixWidth + j] = matrix[loop_cnt%ESCENAS][i][j]; | ||
+ | } | ||
+ | } | ||
+ | unsigned long startMillis= millis(); | ||
+ | unsigned int peakToPeak = 0; // peak-to-peak level | ||
+ | |||
+ | unsigned int signalMax = 0; | ||
+ | unsigned int signalMin = 1024; | ||
+ | |||
+ | // collect data for 50 mS | ||
+ | while (millis() - startMillis < sampleWindow) | ||
+ | { | ||
+ | sample = analogRead(0); | ||
+ | if (sample < 1024) // toss out spurious readings | ||
+ | { | ||
+ | if (sample > signalMax) | ||
+ | { | ||
+ | signalMax = sample; | ||
+ | } | ||
+ | else if (sample < signalMin) | ||
+ | { | ||
+ | signalMin = sample; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | | ||
+ | |||
+ | int cambiarBrillo = map(volts, 0, 5, 0, 100); | ||
+ | Serial.println(cambiarBrillo); | ||
+ | FastLED.show(); | ||
+ | FastLED.setBrightness(cambiarBrillo); | ||
+ | loop_cnt++; | ||
} | } | ||
proyectos/vestuario_aqa.txt · Última modificación: 2021/10/30 23:38 por kz