/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: Encoder Monitor
- Source Code NOT compiled for: ESP32 DevKit V1
- Source Code created on: 2024-10-10 20:55:41
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* afficher dans le port serie un nombre evoluant */
/* grace au codeur */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include //http://github.com/EasyG0ing1/SimpleEncoder
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t r_KY040_CLK_PIN_D16 = 16; // Pin for encoder A
const uint8_t r_KY040_DT_PIN_D17 = 17; // Pin for encoder B
const uint8_t r_KY040_SW_PIN_D18 = 18; // Pin for encoder button
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
// Create an instance of SimpleEncoder with the defined pins
SimpleEncoder encoder(r_KY040_SW_PIN_D18, r_KY040_CLK_PIN_D16, r_KY040_DT_PIN_D17);
void setup(void)
{
// Initialize serial communication at 9600 baud rate
Serial.begin(9600);
// Set the pin modes for the encoder pins
pinMode(r_KY040_CLK_PIN_D16, INPUT);
pinMode(r_KY040_DT_PIN_D17, INPUT);
pinMode(r_KY040_SW_PIN_D18, INPUT_PULLUP);
}
void loop(void)
{
// Check if the encoder value is changing
if (encoder.CHANGING) {
// Print the current value to the serial monitor
Serial.println("Current value is: " + String(encoder.VALUE));
}
}
/* END CODE */