commit a05bce84366b0b8fbd32657525d5f7e11bc31e21 Author: Arturo Corro Date: Wed May 26 09:18:17 2021 -0500 first commit diff --git a/Contador_matriz_led_48x16/Contador_matriz_led_48x16.ino b/Contador_matriz_led_48x16/Contador_matriz_led_48x16.ino new file mode 100644 index 0000000..2d6ec38 --- /dev/null +++ b/Contador_matriz_led_48x16/Contador_matriz_led_48x16.ino @@ -0,0 +1,116 @@ +#include +#include +#include +#include + + +// PINOUT +#define LED_MATRIX_CONTROL_PIN 3 +#define INCREMENT_BUTTON_PIN 4 +#define RESET_BUTTON_PIN 5 + +#define INCREMENT_SENSITIVITY_MILLIS 100 +#define RESET_SENSITIVITY_MILLIS 5000 + +// STATUS BUTTON +#define BUTTON_PUSH 0 +#define BUTTON_IDLE 1 + + +// MATRIX DECLARATION: +// Parameter 1 = width of NeoPixel matrix +// Parameter 2 = height of matrix +// Parameter 3 = pin number (most are valid) +// Parameter 4 = matrix layout flags, add together as needed: +// NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT: +// Position of the FIRST LED in the matrix; pick two, e.g. +// NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner. +// NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal +// rows or in vertical columns, respectively; pick one or the other. +// NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed +// in the same order, or alternate lines reverse direction; pick one. +// See example below for these values in action. +// Parameter 5 = pixel type flags, add together as needed: +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) + +Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(48, 16, LED_MATRIX_CONTROL_PIN, + NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT + + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG, + NEO_GRB + NEO_KHZ800); + +const uint16_t color = matrix.Color(255, 16, 16); + +uint16_t counter; + +uint32_t increment_pressed_millis; +uint32_t reset_pressed_millis; + +uint8_t increment_release; +uint8_t reset_release; + + +void print_count() +{ + matrix.fillScreen(0); + matrix.setCursor(2, 15); + matrix.print(counter); + matrix.show(); +} + +void setup() +{ + pinMode(INCREMENT_BUTTON_PIN, INPUT_PULLUP); + pinMode(RESET_BUTTON_PIN, INPUT_PULLUP); + + matrix.begin(); + matrix.setTextWrap(false); + matrix.setBrightness(5); + matrix.setTextColor(color); + matrix.setFont(&FreeMonoBold12pt7b); + + print_count(); +} + + +void loop() +{ + // Interruptor de incremento + if(digitalRead(INCREMENT_BUTTON_PIN) == BUTTON_PUSH){ + if(increment_pressed_millis == 0) + increment_pressed_millis = millis(); + + // Se supero INCREMENT_SENSITIVITY_MILLIS + if (millis() >= (increment_pressed_millis + INCREMENT_SENSITIVITY_MILLIS) && increment_release == 0){ + increment_release = 1; + counter++; + + print_count(); + } + + }else{ + increment_release = 0; + increment_pressed_millis = 0; + } + + + // Botón de Reseteo + if(digitalRead(RESET_BUTTON_PIN) == BUTTON_PUSH){ + if(reset_pressed_millis == 0) + reset_pressed_millis = millis(); + + // Se supero RESET_SENSITIVITY_MILLIS + if (millis() >= (reset_pressed_millis + RESET_SENSITIVITY_MILLIS) && reset_release == 0){ + reset_release = 1; + counter = 0; + + print_count(); + } + + }else{ + reset_release = 0; + reset_pressed_millis = 0; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..ced77c6 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +### Contador MATRIZ LED + +- Contador basado en Arduino +- Placa utilizada en el proyecto MEGA 2560 +- Se utilizo 3 matrices led WS2812B de 16x16 +- Tamaño total de la matriz de 48x16 +- 768 Leds en total +