From 9aa59208b65b79031170b6b409229f8e493a570b Mon Sep 17 00:00:00 2001 From: DashyFox Date: Fri, 15 Sep 2023 01:15:28 +0300 Subject: [PATCH] ini --- .gitignore | 2 ++ .vscode/arduino.json | 5 +++ MusicRing.ino | 86 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/arduino.json create mode 100644 MusicRing.ino diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d833061 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vscode/* +!.vscode/arduino.json \ No newline at end of file diff --git a/.vscode/arduino.json b/.vscode/arduino.json new file mode 100644 index 0000000..eee793c --- /dev/null +++ b/.vscode/arduino.json @@ -0,0 +1,5 @@ +{ + "port": "COM4", + "board": "arduino:avr:uno", + "sketch": "MusicRing.ino" +} \ No newline at end of file diff --git a/MusicRing.ino b/MusicRing.ino new file mode 100644 index 0000000..2e699ba --- /dev/null +++ b/MusicRing.ino @@ -0,0 +1,86 @@ + + +#define pin_Data 5 // yellow +#define pin_CLK_inside 6 // orange +#define pin_CLK_outside 7 // red + +#define pin_RESET 8 // green +#define pin_OutputEnable 9 // purple + +#define LED_count 32 + + +void shift(uint16_t, bool = true); + +uint8_t position = 1; +void setup() { + pinMode(pin_Data, OUTPUT); + pinMode(pin_CLK_inside, OUTPUT); + pinMode(pin_CLK_outside, OUTPUT); + pinMode(pin_RESET, OUTPUT); + pinMode(pin_OutputEnable, OUTPUT); + + digitalWrite(pin_RESET, HIGH); + + reset(); + + + for (size_t j = 0; j < 1; j++) { + for (size_t i = 1; i <= LED_count * 2; i++) { + digitalWrite(pin_Data, i <= LED_count ? HIGH : LOW); + shift(1); + delay(11); + } + } + + delay(100); + + for (size_t i = 0; i < 3; i++) { + uint8_t del = 42; + digitalWrite(pin_Data, HIGH); + shift(LED_count); + delay(del*1.5); + reset(); + delay(del); + } +} + +void loop() { + if (position >= LED_count) { + point_ini(1); + position = 1; + } + + else shift(1); + delay(1000/ 2 /LED_count); // Если больше 2х перейти на micros +} + +void point_ini(uint8_t width) { + + reset(); + + digitalWrite(pin_Data, HIGH); + shift(width); + digitalWrite(pin_Data, LOW); + +} + +void shift(uint16_t count, bool isVisible = true) { + for (size_t i = 0; i < count; i++) { + + digitalWrite(pin_CLK_inside, HIGH); + if (isVisible) digitalWrite(pin_CLK_outside, HIGH); + + digitalWrite(pin_CLK_inside, LOW); + digitalWrite(pin_CLK_outside, LOW); + + position++; + } +}; + +void reset() { + digitalWrite(pin_RESET, LOW); + digitalWrite(pin_RESET, HIGH); + digitalWrite(pin_CLK_outside, HIGH); + digitalWrite(pin_CLK_outside, LOW); +} \ No newline at end of file