Leitura de pulsos KY-040

Dependencies:   mbed EncoderAli

Files at this revision

API Documentation at this revision

Comitter:
henriquer
Date:
Tue Apr 19 20:41:28 2022 +0000
Parent:
0:862c19aa5239
Commit message:
Leitura de pulsos com encoder KY-040

Changed in this revision

EncoderAli.lib Show diff for this revision Revisions of this file
EncoderKY.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/EncoderAli.lib	Wed Jun 20 15:23:26 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/zelmic/code/EncoderAli/#e1a3b380b0d6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EncoderKY.lib	Tue Apr 19 20:41:28 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/zelmic/code/EncoderAli/#e1a3b380b0d6
--- a/main.cpp	Wed Jun 20 15:23:26 2018 +0000
+++ b/main.cpp	Tue Apr 19 20:41:28 2022 +0000
@@ -1,26 +1,36 @@
-/*
-* Автор - Железняков Андрей
-* Сайт - itworkclub.ru
-* Пример работы с энкодером KY-040 
-*/
+
+//***********************Encoder/Decoder KY-040*******************************//
+
+#include "mbed.h"
+#include "Encoder.h"  // Biblioteca responsável pela leitura dos pulsos
+
+//****************************************************************************//
+//****************************************************************************//
 
 
-#include "mbed.h"
-#include "Encoder.h"
+
+//****************************************************************************//
+int pulse;  // Variável responsável atribuída para leitura dos pulsos
+//****************************************************************************//
 
-DigitalOut Plus(D4); // пины D3 и D4 будем использовать для питания энкодера
-DigitalOut GND(D3);
+
+
+
+
+//****************************************************************************//
 int main()
 {
 
-    Plus = 1;
-    GND = 0;
-    
-    EncoderAli Enc(D6, D7, D5); //DT, CLK, SW
-    Enc.setRange(100,200);
-    while(1)
-    {
-        printf("\n\r Положение: %d; состояние кнопки %d",Enc.getState(), Enc.getButtonState());
-        wait(0.25);
+
+    EncoderAli Enc(PB_13,PB_14,PB_15); //  Ligação do KY-040 nos pinos da Nucleo  -  DT, CLK, SW
+    Enc.setRange(1,20); // Função responsável por setar o Range do Encoder
+    while(1) {
+        printf("\n\r PULSOS: %d; ",Enc.getState()); // ,Enc.getState() -> Função Responsável por ler os pulsos   ,Enc.getButtonState()-> Função responsável por ler o estado do botão SW
+        
+        pulse = Enc.getState();
+        
+
     }
 }
+
+//****************************************************************************//
\ No newline at end of file