Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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 Display"
- - Source Code compiled for: Arduino Nano ESP32
- - Source Code created on: 2024-06-22 23:29:18
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* displays number from a dial that shows 100 */
- /* graduation in a 360 rotation in 2 decimal points */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <SimpleEncoder.h> //http://github.com/EasyG0ing1/SimpleEncoder
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t encoder_KY_040_CLK_PIN_D2 = 2;
- const uint8_t encoder_KY_040_DT_PIN_D3 = 3;
- const uint8_t encoder_KY_040_SW_PIN_D4 = 4;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- SimpleEncoder encoder(encoder_KY_040_SW_PIN_D4, encoder_KY_040_CLK_PIN_D2, encoder_KY_040_DT_PIN_D3);
- void setup(void) {
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode(encoder_KY_040_CLK_PIN_D2, INPUT);
- pinMode(encoder_KY_040_DT_PIN_D3, INPUT);
- pinMode(encoder_KY_040_SW_PIN_D4, INPUT_PULLUP);
- }
- void loop(void) {
- // put your main code here, to run repeatedly:
- if (encoder.CHANGING) {
- // Display the current value with 2 decimal points
- float value = encoder.VALUE / 100.0;
- Serial.println("Current value is: " + String(value, 2));
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement