Carro de la compra

No hay artículos en el carro

No hay artículos en el carro

Taiss / 5 unidades KY-040 Módulo codificador giratorio con 15 x 16,5 mm con tapa de perillas

Envío gratis en pedidos superiores a Mex $600.00

Mex $232.00

Mex $ 132 .00 Mex $132.00

En stock
  • Voltaje de funcionamiento: 5 V; Un número redondo de pulsos: 20
  • El material de la tapa de la perilla: aleación de aluminio; las especificaciones de la tapa de la perilla: diámetro: 15 mm. Altura: 16,5 mm
  • El codificador giratorio puede contar el número de pulsos de salida durante la rotación en la dirección positiva y la dirección inversa a través de la rotación y este número de rotación no está limitado
  • Con la tecla del codificador giratorio, puedes restablecer el estado inicial, es decir, contando desde 0
  • Contenido del paquete: 5 módulos codificadores giratorios + 5 pomos negros.



Descripción del producto

1
1

Descripción del producto:

Acerca de los productos

Nombre del producto: módulo codificador rotativo

Modelo del producto: KY-040

Voltaje de funcionamiento: 5 V. Un número redondo de pulsos: 20

El codificador giratorio puede contar el número de pulsos de salida durante la rotación en la dirección positiva y la dirección inversa a través de la rotación y estos recuentos de rotación no están limitados. Con la tecla del codificador giratorio, puedes restablecer el estado inicial, es decir, contando desde 0.

1


Stephane Alarie
Comentado en Canadá el 14 de marzo de 2025
Conforme a ce que j'ai commandé.
Stephane Alarie
Comentado en Canadá el 14 de marzo de 2025
Conforme a ce que j'ai commandé.
Stephane Alarie
Comentado en Canadá el 14 de marzo de 2025
Conforme a ce que j'ai commandé.
Stephane Alarie
Comentado en Canadá el 14 de marzo de 2025
Conforme a ce que j'ai commandé.
Stephane Alarie
Comentado en Canadá el 14 de marzo de 2025
Conforme a ce que j'ai commandé.
Stephane Alarie
Comentado en Canadá el 14 de marzo de 2025
Conforme a ce que j'ai commandé.
Stephane Alarie
Comentado en Canadá el 14 de marzo de 2025
Conforme a ce que j'ai commandé.
Stephane Alarie
Comentado en Canadá el 14 de marzo de 2025
Conforme a ce que j'ai commandé.
Customer
Comentado en Canadá el 12 de febrero de 2025
I'm using them with WLED and they work flawlessly. I'm using the rotary encoder and four line display usermod that I customized and it's amazing now. Brightness adjustment with the knob, double click to change presets and long press to power off and on. Cut the side with the holes off to fit it in my car.
Customer
Comentado en Canadá el 12 de febrero de 2025
I'm using them with WLED and they work flawlessly. I'm using the rotary encoder and four line display usermod that I customized and it's amazing now. Brightness adjustment with the knob, double click to change presets and long press to power off and on. Cut the side with the holes off to fit it in my car.
Customer
Comentado en Canadá el 12 de febrero de 2025
I'm using them with WLED and they work flawlessly. I'm using the rotary encoder and four line display usermod that I customized and it's amazing now. Brightness adjustment with the knob, double click to change presets and long press to power off and on. Cut the side with the holes off to fit it in my car.
Customer
Comentado en Canadá el 12 de febrero de 2025
I'm using them with WLED and they work flawlessly. I'm using the rotary encoder and four line display usermod that I customized and it's amazing now. Brightness adjustment with the knob, double click to change presets and long press to power off and on. Cut the side with the holes off to fit it in my car.
Customer
Comentado en Canadá el 12 de febrero de 2025
I'm using them with WLED and they work flawlessly. I'm using the rotary encoder and four line display usermod that I customized and it's amazing now. Brightness adjustment with the knob, double click to change presets and long press to power off and on. Cut the side with the holes off to fit it in my car.
Customer
Comentado en Canadá el 12 de febrero de 2025
I'm using them with WLED and they work flawlessly. I'm using the rotary encoder and four line display usermod that I customized and it's amazing now. Brightness adjustment with the knob, double click to change presets and long press to power off and on. Cut the side with the holes off to fit it in my car.
Customer
Comentado en Canadá el 12 de febrero de 2025
I'm using them with WLED and they work flawlessly. I'm using the rotary encoder and four line display usermod that I customized and it's amazing now. Brightness adjustment with the knob, double click to change presets and long press to power off and on. Cut the side with the holes off to fit it in my car.
Customer
Comentado en Canadá el 12 de febrero de 2025
I'm using them with WLED and they work flawlessly. I'm using the rotary encoder and four line display usermod that I customized and it's amazing now. Brightness adjustment with the knob, double click to change presets and long press to power off and on. Cut the side with the holes off to fit it in my car.
Marc
Comentado en Canadá el 18 de julio de 2024
emballé sans protection (dans un sac uniquement) alors j’ai reçu les items avec les broches croches.. les encodeurs rotatifs semblaient vieux car les contacts donnaient des incréments/décréments erratiques (comparé avec ma référence qui fonctionne très bien).. items finalement retournés..
Marc
Comentado en Canadá el 18 de julio de 2024
emballé sans protection (dans un sac uniquement) alors j’ai reçu les items avec les broches croches.. les encodeurs rotatifs semblaient vieux car les contacts donnaient des incréments/décréments erratiques (comparé avec ma référence qui fonctionne très bien).. items finalement retournés..
Marc
Comentado en Canadá el 18 de julio de 2024
emballé sans protection (dans un sac uniquement) alors j’ai reçu les items avec les broches croches.. les encodeurs rotatifs semblaient vieux car les contacts donnaient des incréments/décréments erratiques (comparé avec ma référence qui fonctionne très bien).. items finalement retournés..
Marc
Comentado en Canadá el 18 de julio de 2024
emballé sans protection (dans un sac uniquement) alors j’ai reçu les items avec les broches croches.. les encodeurs rotatifs semblaient vieux car les contacts donnaient des incréments/décréments erratiques (comparé avec ma référence qui fonctionne très bien).. items finalement retournés..
Marc
Comentado en Canadá el 18 de julio de 2024
emballé sans protection (dans un sac uniquement) alors j’ai reçu les items avec les broches croches.. les encodeurs rotatifs semblaient vieux car les contacts donnaient des incréments/décréments erratiques (comparé avec ma référence qui fonctionne très bien).. items finalement retournés..
Marc
Comentado en Canadá el 18 de julio de 2024
emballé sans protection (dans un sac uniquement) alors j’ai reçu les items avec les broches croches.. les encodeurs rotatifs semblaient vieux car les contacts donnaient des incréments/décréments erratiques (comparé avec ma référence qui fonctionne très bien).. items finalement retournés..
Marc
Comentado en Canadá el 18 de julio de 2024
emballé sans protection (dans un sac uniquement) alors j’ai reçu les items avec les broches croches.. les encodeurs rotatifs semblaient vieux car les contacts donnaient des incréments/décréments erratiques (comparé avec ma référence qui fonctionne très bien).. items finalement retournés..
Marc
Comentado en Canadá el 18 de julio de 2024
emballé sans protection (dans un sac uniquement) alors j’ai reçu les items avec les broches croches.. les encodeurs rotatifs semblaient vieux car les contacts donnaient des incréments/décréments erratiques (comparé avec ma référence qui fonctionne très bien).. items finalement retournés..
Kathleen H.
Comentado en los Estados Unidos el 20 de mayo de 2024
I had a big problem with switch bounce when connecting clk, data, and switch to my Arduino Uno R4 Wifi, using the KY040 code from MediaFire. That program kept firing off a reset (switch depress) even when I was only rotating the dial. I also noticed that the switch was missing the 10KOhm pull-up resistor for the switch line, so I popped one off another switch and soldered that in. Bounce gone completely, and I can count up or down to my heart's content without a reset. Very nice, other than needing to buy a bunch of 10K 0805 chip resistors. Note that the program was supposed to provide pull-ups from the board, but that apparently did not happen properly. I note that two of the pins were analog optional pins, so perhaps that caused an issue. In any case, the switches appear to work well once modified.
Kathleen H.
Comentado en los Estados Unidos el 20 de mayo de 2024
I had a big problem with switch bounce when connecting clk, data, and switch to my Arduino Uno R4 Wifi, using the KY040 code from MediaFire. That program kept firing off a reset (switch depress) even when I was only rotating the dial. I also noticed that the switch was missing the 10KOhm pull-up resistor for the switch line, so I popped one off another switch and soldered that in. Bounce gone completely, and I can count up or down to my heart's content without a reset. Very nice, other than needing to buy a bunch of 10K 0805 chip resistors. Note that the program was supposed to provide pull-ups from the board, but that apparently did not happen properly. I note that two of the pins were analog optional pins, so perhaps that caused an issue. In any case, the switches appear to work well once modified.
Kathleen H.
Comentado en los Estados Unidos el 20 de mayo de 2024
I had a big problem with switch bounce when connecting clk, data, and switch to my Arduino Uno R4 Wifi, using the KY040 code from MediaFire. That program kept firing off a reset (switch depress) even when I was only rotating the dial. I also noticed that the switch was missing the 10KOhm pull-up resistor for the switch line, so I popped one off another switch and soldered that in. Bounce gone completely, and I can count up or down to my heart's content without a reset. Very nice, other than needing to buy a bunch of 10K 0805 chip resistors. Note that the program was supposed to provide pull-ups from the board, but that apparently did not happen properly. I note that two of the pins were analog optional pins, so perhaps that caused an issue. In any case, the switches appear to work well once modified.
Kathleen H.
Comentado en los Estados Unidos el 20 de mayo de 2024
I had a big problem with switch bounce when connecting clk, data, and switch to my Arduino Uno R4 Wifi, using the KY040 code from MediaFire. That program kept firing off a reset (switch depress) even when I was only rotating the dial. I also noticed that the switch was missing the 10KOhm pull-up resistor for the switch line, so I popped one off another switch and soldered that in. Bounce gone completely, and I can count up or down to my heart's content without a reset. Very nice, other than needing to buy a bunch of 10K 0805 chip resistors. Note that the program was supposed to provide pull-ups from the board, but that apparently did not happen properly. I note that two of the pins were analog optional pins, so perhaps that caused an issue. In any case, the switches appear to work well once modified.
Kathleen H.
Comentado en los Estados Unidos el 20 de mayo de 2024
I had a big problem with switch bounce when connecting clk, data, and switch to my Arduino Uno R4 Wifi, using the KY040 code from MediaFire. That program kept firing off a reset (switch depress) even when I was only rotating the dial. I also noticed that the switch was missing the 10KOhm pull-up resistor for the switch line, so I popped one off another switch and soldered that in. Bounce gone completely, and I can count up or down to my heart's content without a reset. Very nice, other than needing to buy a bunch of 10K 0805 chip resistors. Note that the program was supposed to provide pull-ups from the board, but that apparently did not happen properly. I note that two of the pins were analog optional pins, so perhaps that caused an issue. In any case, the switches appear to work well once modified.
Kathleen H.
Comentado en los Estados Unidos el 20 de mayo de 2024
I had a big problem with switch bounce when connecting clk, data, and switch to my Arduino Uno R4 Wifi, using the KY040 code from MediaFire. That program kept firing off a reset (switch depress) even when I was only rotating the dial. I also noticed that the switch was missing the 10KOhm pull-up resistor for the switch line, so I popped one off another switch and soldered that in. Bounce gone completely, and I can count up or down to my heart's content without a reset. Very nice, other than needing to buy a bunch of 10K 0805 chip resistors. Note that the program was supposed to provide pull-ups from the board, but that apparently did not happen properly. I note that two of the pins were analog optional pins, so perhaps that caused an issue. In any case, the switches appear to work well once modified.
Kathleen H.
Comentado en los Estados Unidos el 20 de mayo de 2024
I had a big problem with switch bounce when connecting clk, data, and switch to my Arduino Uno R4 Wifi, using the KY040 code from MediaFire. That program kept firing off a reset (switch depress) even when I was only rotating the dial. I also noticed that the switch was missing the 10KOhm pull-up resistor for the switch line, so I popped one off another switch and soldered that in. Bounce gone completely, and I can count up or down to my heart's content without a reset. Very nice, other than needing to buy a bunch of 10K 0805 chip resistors. Note that the program was supposed to provide pull-ups from the board, but that apparently did not happen properly. I note that two of the pins were analog optional pins, so perhaps that caused an issue. In any case, the switches appear to work well once modified.
Kathleen H.
Comentado en los Estados Unidos el 20 de mayo de 2024
I had a big problem with switch bounce when connecting clk, data, and switch to my Arduino Uno R4 Wifi, using the KY040 code from MediaFire. That program kept firing off a reset (switch depress) even when I was only rotating the dial. I also noticed that the switch was missing the 10KOhm pull-up resistor for the switch line, so I popped one off another switch and soldered that in. Bounce gone completely, and I can count up or down to my heart's content without a reset. Very nice, other than needing to buy a bunch of 10K 0805 chip resistors. Note that the program was supposed to provide pull-ups from the board, but that apparently did not happen properly. I note that two of the pins were analog optional pins, so perhaps that caused an issue. In any case, the switches appear to work well once modified.
Davis Hammon
Comentado en los Estados Unidos el 25 de junio de 2021
They work great, ... as long as the noise is filtered out. I needed to run the signal on wire over 45 feet. This destroyed any ability to simply read DT -- it was just bouncing all over. I tried putting in a 0.1uF cap and tried pull up resistors. Neither was able to filter out the noise. So I wrote some code that seems to be working great. This should run on Arduino and similar devices. Keep in mind that this approach does NOT use interrupts, so it is possible that turns could possibly be missed if your MCU gets busy on other things (though unlikely, unless you're running very long processes).uint16_t debounceDuration = 100;uint8_t clkVal = 0;uint8_t dtVal = 0;uint8_t dtValPrev = 0;uint32_t dtValLows = 0;uint32_t dtValHighs = 0;uint32_t millisR = 0;bool activePeriod = false;bool dir = false;uint8_t clkPin = A0;uint8_t. dkPin = A1;uint32_t currentMillis = 0;void setup() {pinMode(clkPin, INPUT_PULLUP);pinMode(dkPin, INPUT_PULLUP);}void loop() {currentMillis = millis();clkVal = pinReadFast(clkPin);if (clkVal == LOW && !activePeriod && currentMillis - millisR > debounceDuration) { // happens one time once CLK goes low.millisR = currentMillis;activePeriod = true;dtValLows = 0;dtValHighs = 0;}if (activePeriod) {dtValPrev = dtVal;dtVal = pinReadFast(dkPin);if (currentMillis - millisR if (dtVal == HIGH) dtValHighs++; else dtValLows++;}}if (currentMillis - millisR > debounceDuration && activePeriod) { // finished active period. fired oncedir = (dtValHighs > dtValLows);activePeriod = false;Serial.print("dir: ");Serial.println(dir);}}
Davis Hammon
Comentado en los Estados Unidos el 25 de junio de 2021
They work great, ... as long as the noise is filtered out. I needed to run the signal on wire over 45 feet. This destroyed any ability to simply read DT -- it was just bouncing all over. I tried putting in a 0.1uF cap and tried pull up resistors. Neither was able to filter out the noise. So I wrote some code that seems to be working great. This should run on Arduino and similar devices. Keep in mind that this approach does NOT use interrupts, so it is possible that turns could possibly be missed if your MCU gets busy on other things (though unlikely, unless you're running very long processes).uint16_t debounceDuration = 100;uint8_t clkVal = 0;uint8_t dtVal = 0;uint8_t dtValPrev = 0;uint32_t dtValLows = 0;uint32_t dtValHighs = 0;uint32_t millisR = 0;bool activePeriod = false;bool dir = false;uint8_t clkPin = A0;uint8_t. dkPin = A1;uint32_t currentMillis = 0;void setup() {pinMode(clkPin, INPUT_PULLUP);pinMode(dkPin, INPUT_PULLUP);}void loop() {currentMillis = millis();clkVal = pinReadFast(clkPin);if (clkVal == LOW && !activePeriod && currentMillis - millisR > debounceDuration) { // happens one time once CLK goes low.millisR = currentMillis;activePeriod = true;dtValLows = 0;dtValHighs = 0;}if (activePeriod) {dtValPrev = dtVal;dtVal = pinReadFast(dkPin);if (currentMillis - millisR if (dtVal == HIGH) dtValHighs++; else dtValLows++;}}if (currentMillis - millisR > debounceDuration && activePeriod) { // finished active period. fired oncedir = (dtValHighs > dtValLows);activePeriod = false;Serial.print("dir: ");Serial.println(dir);}}
Davis Hammon
Comentado en los Estados Unidos el 25 de junio de 2021
They work great, ... as long as the noise is filtered out. I needed to run the signal on wire over 45 feet. This destroyed any ability to simply read DT -- it was just bouncing all over. I tried putting in a 0.1uF cap and tried pull up resistors. Neither was able to filter out the noise. So I wrote some code that seems to be working great. This should run on Arduino and similar devices. Keep in mind that this approach does NOT use interrupts, so it is possible that turns could possibly be missed if your MCU gets busy on other things (though unlikely, unless you're running very long processes).uint16_t debounceDuration = 100;uint8_t clkVal = 0;uint8_t dtVal = 0;uint8_t dtValPrev = 0;uint32_t dtValLows = 0;uint32_t dtValHighs = 0;uint32_t millisR = 0;bool activePeriod = false;bool dir = false;uint8_t clkPin = A0;uint8_t. dkPin = A1;uint32_t currentMillis = 0;void setup() {pinMode(clkPin, INPUT_PULLUP);pinMode(dkPin, INPUT_PULLUP);}void loop() {currentMillis = millis();clkVal = pinReadFast(clkPin);if (clkVal == LOW && !activePeriod && currentMillis - millisR > debounceDuration) { // happens one time once CLK goes low.millisR = currentMillis;activePeriod = true;dtValLows = 0;dtValHighs = 0;}if (activePeriod) {dtValPrev = dtVal;dtVal = pinReadFast(dkPin);if (currentMillis - millisR if (dtVal == HIGH) dtValHighs++; else dtValLows++;}}if (currentMillis - millisR > debounceDuration && activePeriod) { // finished active period. fired oncedir = (dtValHighs > dtValLows);activePeriod = false;Serial.print("dir: ");Serial.println(dir);}}
Davis Hammon
Comentado en los Estados Unidos el 25 de junio de 2021
They work great, ... as long as the noise is filtered out. I needed to run the signal on wire over 45 feet. This destroyed any ability to simply read DT -- it was just bouncing all over. I tried putting in a 0.1uF cap and tried pull up resistors. Neither was able to filter out the noise. So I wrote some code that seems to be working great. This should run on Arduino and similar devices. Keep in mind that this approach does NOT use interrupts, so it is possible that turns could possibly be missed if your MCU gets busy on other things (though unlikely, unless you're running very long processes).uint16_t debounceDuration = 100;uint8_t clkVal = 0;uint8_t dtVal = 0;uint8_t dtValPrev = 0;uint32_t dtValLows = 0;uint32_t dtValHighs = 0;uint32_t millisR = 0;bool activePeriod = false;bool dir = false;uint8_t clkPin = A0;uint8_t. dkPin = A1;uint32_t currentMillis = 0;void setup() {pinMode(clkPin, INPUT_PULLUP);pinMode(dkPin, INPUT_PULLUP);}void loop() {currentMillis = millis();clkVal = pinReadFast(clkPin);if (clkVal == LOW && !activePeriod && currentMillis - millisR > debounceDuration) { // happens one time once CLK goes low.millisR = currentMillis;activePeriod = true;dtValLows = 0;dtValHighs = 0;}if (activePeriod) {dtValPrev = dtVal;dtVal = pinReadFast(dkPin);if (currentMillis - millisR if (dtVal == HIGH) dtValHighs++; else dtValLows++;}}if (currentMillis - millisR > debounceDuration && activePeriod) { // finished active period. fired oncedir = (dtValHighs > dtValLows);activePeriod = false;Serial.print("dir: ");Serial.println(dir);}}
Davis Hammon
Comentado en los Estados Unidos el 25 de junio de 2021
They work great, ... as long as the noise is filtered out. I needed to run the signal on wire over 45 feet. This destroyed any ability to simply read DT -- it was just bouncing all over. I tried putting in a 0.1uF cap and tried pull up resistors. Neither was able to filter out the noise. So I wrote some code that seems to be working great. This should run on Arduino and similar devices. Keep in mind that this approach does NOT use interrupts, so it is possible that turns could possibly be missed if your MCU gets busy on other things (though unlikely, unless you're running very long processes).uint16_t debounceDuration = 100;uint8_t clkVal = 0;uint8_t dtVal = 0;uint8_t dtValPrev = 0;uint32_t dtValLows = 0;uint32_t dtValHighs = 0;uint32_t millisR = 0;bool activePeriod = false;bool dir = false;uint8_t clkPin = A0;uint8_t. dkPin = A1;uint32_t currentMillis = 0;void setup() {pinMode(clkPin, INPUT_PULLUP);pinMode(dkPin, INPUT_PULLUP);}void loop() {currentMillis = millis();clkVal = pinReadFast(clkPin);if (clkVal == LOW && !activePeriod && currentMillis - millisR > debounceDuration) { // happens one time once CLK goes low.millisR = currentMillis;activePeriod = true;dtValLows = 0;dtValHighs = 0;}if (activePeriod) {dtValPrev = dtVal;dtVal = pinReadFast(dkPin);if (currentMillis - millisR if (dtVal == HIGH) dtValHighs++; else dtValLows++;}}if (currentMillis - millisR > debounceDuration && activePeriod) { // finished active period. fired oncedir = (dtValHighs > dtValLows);activePeriod = false;Serial.print("dir: ");Serial.println(dir);}}
Davis Hammon
Comentado en los Estados Unidos el 25 de junio de 2021
They work great, ... as long as the noise is filtered out. I needed to run the signal on wire over 45 feet. This destroyed any ability to simply read DT -- it was just bouncing all over. I tried putting in a 0.1uF cap and tried pull up resistors. Neither was able to filter out the noise. So I wrote some code that seems to be working great. This should run on Arduino and similar devices. Keep in mind that this approach does NOT use interrupts, so it is possible that turns could possibly be missed if your MCU gets busy on other things (though unlikely, unless you're running very long processes).uint16_t debounceDuration = 100;uint8_t clkVal = 0;uint8_t dtVal = 0;uint8_t dtValPrev = 0;uint32_t dtValLows = 0;uint32_t dtValHighs = 0;uint32_t millisR = 0;bool activePeriod = false;bool dir = false;uint8_t clkPin = A0;uint8_t. dkPin = A1;uint32_t currentMillis = 0;void setup() {pinMode(clkPin, INPUT_PULLUP);pinMode(dkPin, INPUT_PULLUP);}void loop() {currentMillis = millis();clkVal = pinReadFast(clkPin);if (clkVal == LOW && !activePeriod && currentMillis - millisR > debounceDuration) { // happens one time once CLK goes low.millisR = currentMillis;activePeriod = true;dtValLows = 0;dtValHighs = 0;}if (activePeriod) {dtValPrev = dtVal;dtVal = pinReadFast(dkPin);if (currentMillis - millisR if (dtVal == HIGH) dtValHighs++; else dtValLows++;}}if (currentMillis - millisR > debounceDuration && activePeriod) { // finished active period. fired oncedir = (dtValHighs > dtValLows);activePeriod = false;Serial.print("dir: ");Serial.println(dir);}}
Davis Hammon
Comentado en los Estados Unidos el 25 de junio de 2021
They work great, ... as long as the noise is filtered out. I needed to run the signal on wire over 45 feet. This destroyed any ability to simply read DT -- it was just bouncing all over. I tried putting in a 0.1uF cap and tried pull up resistors. Neither was able to filter out the noise. So I wrote some code that seems to be working great. This should run on Arduino and similar devices. Keep in mind that this approach does NOT use interrupts, so it is possible that turns could possibly be missed if your MCU gets busy on other things (though unlikely, unless you're running very long processes).uint16_t debounceDuration = 100;uint8_t clkVal = 0;uint8_t dtVal = 0;uint8_t dtValPrev = 0;uint32_t dtValLows = 0;uint32_t dtValHighs = 0;uint32_t millisR = 0;bool activePeriod = false;bool dir = false;uint8_t clkPin = A0;uint8_t. dkPin = A1;uint32_t currentMillis = 0;void setup() {pinMode(clkPin, INPUT_PULLUP);pinMode(dkPin, INPUT_PULLUP);}void loop() {currentMillis = millis();clkVal = pinReadFast(clkPin);if (clkVal == LOW && !activePeriod && currentMillis - millisR > debounceDuration) { // happens one time once CLK goes low.millisR = currentMillis;activePeriod = true;dtValLows = 0;dtValHighs = 0;}if (activePeriod) {dtValPrev = dtVal;dtVal = pinReadFast(dkPin);if (currentMillis - millisR if (dtVal == HIGH) dtValHighs++; else dtValLows++;}}if (currentMillis - millisR > debounceDuration && activePeriod) { // finished active period. fired oncedir = (dtValHighs > dtValLows);activePeriod = false;Serial.print("dir: ");Serial.println(dir);}}
Davis Hammon
Comentado en los Estados Unidos el 25 de junio de 2021
They work great, ... as long as the noise is filtered out. I needed to run the signal on wire over 45 feet. This destroyed any ability to simply read DT -- it was just bouncing all over. I tried putting in a 0.1uF cap and tried pull up resistors. Neither was able to filter out the noise. So I wrote some code that seems to be working great. This should run on Arduino and similar devices. Keep in mind that this approach does NOT use interrupts, so it is possible that turns could possibly be missed if your MCU gets busy on other things (though unlikely, unless you're running very long processes).uint16_t debounceDuration = 100;uint8_t clkVal = 0;uint8_t dtVal = 0;uint8_t dtValPrev = 0;uint32_t dtValLows = 0;uint32_t dtValHighs = 0;uint32_t millisR = 0;bool activePeriod = false;bool dir = false;uint8_t clkPin = A0;uint8_t. dkPin = A1;uint32_t currentMillis = 0;void setup() {pinMode(clkPin, INPUT_PULLUP);pinMode(dkPin, INPUT_PULLUP);}void loop() {currentMillis = millis();clkVal = pinReadFast(clkPin);if (clkVal == LOW && !activePeriod && currentMillis - millisR > debounceDuration) { // happens one time once CLK goes low.millisR = currentMillis;activePeriod = true;dtValLows = 0;dtValHighs = 0;}if (activePeriod) {dtValPrev = dtVal;dtVal = pinReadFast(dkPin);if (currentMillis - millisR if (dtVal == HIGH) dtValHighs++; else dtValLows++;}}if (currentMillis - millisR > debounceDuration && activePeriod) { // finished active period. fired oncedir = (dtValHighs > dtValLows);activePeriod = false;Serial.print("dir: ");Serial.println(dir);}}
Productos recomendados

Mex $2,028.53

Mex $ 973 .00 Mex $973.00

4.6
Elegir

Mex $141.97

Mex $ 85 .00 Mex $85.00

4.6
Elegir

Mex $2,379.11

Mex $ 999 .00 Mex $999.00

4.4
Elegir

Mex $6,706.01

Mex $ 1,881 .00 Mex $1,881.00

4.9
Elegir