informatica:arduino:esp32:cronometro
This is an old revision of the document!
tags: cronómetro cronometro
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
long duration;
//Vcc - Vcc
//Gnd - Gnd
//Din - Mosi (Pin 11)
//Cs - SS (Pin 10)
//Clk - Sck (Pin 18)
const int pinCS = 5;
int d=0;
int s=0;
int S=0;
int m=0;
int resetmillis=0;
const int trigPin = 2;
const int echoPin = 4;
const int numberOfHorizontalDisplays = 4;
//const int numberOfHorizontalDisplays = 1; // retirar comentario para una sola matriz
const int numberOfVerticalDisplays = 1;
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
String tape = "0123456789: "; //tu mensaje
const int spacer = 1;
const int width = 5 + spacer; // The font width is 5 pixels
void setup() {
Serial.begin(115200); // Starts the serial communication
matrix.setIntensity(7); // Use a value between 0 and 15 for brightness
//
matrix.setPosition(0, 0, 0); // The first display is at <0, 0>
matrix.setPosition(1, 1, 0); // The second display is at <1, 0>
matrix.setPosition(2, 2, 0); // The third display is at <2, 0>
matrix.setPosition(3, 3, 0); // And the last display is at <3, 0>
matrix.setRotation(0, 1); // Display is position upside down
matrix.setRotation(1, 1); // Display is position upside down
matrix.setRotation(2, 1); // Display is position upside down
matrix.setRotation(3, 1); // Display is position upside down
resetmillis=millis();
}
void loop() {
//Primero dibujamos los 2 puntos tape[10] son los puntos en la cadena tape y 9 y 23 la posición empezando a contar por la izquierda teniendo los pins a la izquierda y el 0 es la tercera columna
//Cada número ocupa 5 espacios, mas 1 de separación a cada lado
//matrix.drawChar(23, 1, tape[10], HIGH, LOW, 1);
//matrix.drawChar(9, 1, tape[10], HIGH, LOW, 1);
matrix.drawChar(23, 1, tape[10], HIGH, LOW, 1);
matrix.drawChar(9, 1, tape[10], HIGH, LOW, 1);
int Tmillis=(millis()-resetmillis)/100;
int D = Tmillis/60;
int m = Tmillis/600;
int S = Tmillis/100-m*6;
int s = Tmillis/10-m*60-S*10;
int d = Tmillis-m*600-S*100-s*10;
matrix.drawChar(27, 1, tape[d], HIGH, LOW, 1);
matrix.drawChar(19, 1, tape[s], HIGH, LOW, 1);
matrix.drawChar(13, 1, tape[S], HIGH, LOW, 1);
matrix.drawChar(5, 1, tape[m], HIGH, LOW, 1);
Serial.println(tape[d]);
matrix.write(); // Send bitmap to display
delay(100);
}
informatica/arduino/esp32/cronometro.1681733629.txt.gz · Last modified: by jose
