From 87614ebf87336a6c0b0559dd5da60a531d1c2344 Mon Sep 17 00:00:00 2001 From: Tilman Date: Sun, 29 Jan 2023 09:05:28 +0100 Subject: [PATCH] Serial output for debugging --- .../nano_ky-040_rotary/nano_ky-040_rotary.ino | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/nano/nano_ky-040_rotary/nano_ky-040_rotary.ino b/nano/nano_ky-040_rotary/nano_ky-040_rotary.ino index a0bf547..848cb5a 100644 --- a/nano/nano_ky-040_rotary/nano_ky-040_rotary.ino +++ b/nano/nano_ky-040_rotary/nano_ky-040_rotary.ino @@ -36,6 +36,8 @@ int value = 60; // 0-255 void setup() { + Serial.begin(115200); + pinMode(CLK,INPUT); pinMode(DT,INPUT); pinMode(SW, INPUT_PULLUP); @@ -46,6 +48,8 @@ void setup() { pixels.begin(); // initialize NeoPixel library. pixels.fill(pixels.gamma32(pixels.ColorHSV(hue, saturation, value)), 0, NUMPIXELS); pixels.show(); + + Serial.println("PIXELS"); } void loop() { @@ -57,6 +61,7 @@ void loop() { btnState = digitalRead(SW); if (digitalRead(DT) != currentStateCLK) { + currentDir ="CW"; if (btnState == LOW) { hue += HUE_STEP; if (hue > 65535) { @@ -74,6 +79,7 @@ void loop() { } } } else { + currentDir ="CCW"; if (btnState == LOW) { hue -= HUE_STEP; if (hue < 0) { @@ -91,6 +97,15 @@ void loop() { } } } + + Serial.print("Direction: "); + Serial.print(currentDir); + Serial.print(" | Hue: "); + Serial.print(hue); + Serial.print(" | Sat: "); + Serial.print(saturation); + Serial.print(" | Val: "); + Serial.println(value); pixels.fill(pixels.gamma32(pixels.ColorHSV(hue, saturation, value)), 0, NUMPIXELS); pixels.show(); @@ -99,6 +114,7 @@ void loop() { btnState = digitalRead(SW2); if (digitalRead(DT2) != currentStateCLK2) { + currentDir ="CW"; if (btnState == LOW) { hue += HUE_STEP; if (hue > 65535) { @@ -116,6 +132,7 @@ void loop() { } } } else { + currentDir ="CCW"; if (btnState == LOW) { hue -= HUE_STEP; if (hue < 0) { @@ -134,6 +151,17 @@ void loop() { } } + Serial.print("Direction 2: "); + Serial.print(currentDir); + Serial.print(" | Button State: "); + Serial.print(btnState); + Serial.print(" | Hue: "); + Serial.print(hue); + Serial.print(" | Sat: "); + Serial.print(saturation); + Serial.print(" | Val: "); + Serial.println(value); + pixels.fill(pixels.gamma32(pixels.ColorHSV(hue, saturation, value)), 0, NUMPIXELS); pixels.show(); }