Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/AlexGyver/Arduino_Ambilight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex <beragumbo@ya.ru>2017-08-26 02:11:18 +0300
committerAlex <beragumbo@ya.ru>2017-08-26 02:11:18 +0300
commite10e5932de63b1ecbf279970242f61cd578e9f30 (patch)
treeec8c6cb73abeccb25868435487fba913cfe1e81a
parentc980e652cad9483c02519dc95ddb049f43ab4a43 (diff)
Динамическая подсветка для монитора
Динамическая подсветка (Ambilight) для монитора компьютера на Ардуино
-rw-r--r--AmbiBox_setup_2.1.7.exebin0 -> 10256517 bytes
-rw-r--r--FastLED-master.zipbin0 -> 270806 bytes
-rw-r--r--Gyver_Ambilight/Gyver_Ambilight.ino87
3 files changed, 87 insertions, 0 deletions
diff --git a/AmbiBox_setup_2.1.7.exe b/AmbiBox_setup_2.1.7.exe
new file mode 100644
index 0000000..5e6cae5
--- /dev/null
+++ b/AmbiBox_setup_2.1.7.exe
Binary files differ
diff --git a/FastLED-master.zip b/FastLED-master.zip
new file mode 100644
index 0000000..f749554
--- /dev/null
+++ b/FastLED-master.zip
Binary files differ
diff --git a/Gyver_Ambilight/Gyver_Ambilight.ino b/Gyver_Ambilight/Gyver_Ambilight.ino
new file mode 100644
index 0000000..fe9d9a5
--- /dev/null
+++ b/Gyver_Ambilight/Gyver_Ambilight.ino
@@ -0,0 +1,87 @@
+/*
+ Управление лентой на WS2812 с компьютера + динамическая яркость
+ Создано не знаю кем, допилил и перевёл AlexGyver http://alexgyver.ru/
+ 2017
+*/
+//----------------------НАСТРОЙКИ-----------------------
+#define NUM_LEDS 98 // число светодиодов в ленте
+#define DI_PIN 13 // пин, к которому подключена лента
+
+#define start_flashes 0 // проверка цветов при запуске (1 - включить, 0 - выключить)
+
+#define auto_bright 0 // автоматическая подстройка яркости от уровня внешнего освещения (1 - включить, 0 - выключить)
+#define max_bright 150 // максимальная яркость (0 - 255)
+#define min_bright 10 // минимальная яркость (0 - 255)
+//----------------------НАСТРОЙКИ-----------------------
+
+int new_bright;
+unsigned long bright_timer;
+#define serialRate 115200 // скорость связи с ПК
+uint8_t prefix[] = {'A', 'd', 'a'}, hi, lo, chk, i; // кодовое слово Ada для связи
+#include <FastLED.h>
+CRGB leds[NUM_LEDS]; // создаём ленту
+
+void setup()
+{
+ FastLED.addLeds<WS2812, DI_PIN, GRB>(leds, NUM_LEDS); // инициализация светодиодов
+
+ // вспышки красным синим и зелёным при запуске (можно отключить)
+ if (start_flashes) {
+ LEDS.showColor(CRGB(255, 0, 0));
+ delay(500);
+ LEDS.showColor(CRGB(0, 255, 0));
+ delay(500);
+ LEDS.showColor(CRGB(0, 0, 255));
+ delay(500);
+ LEDS.showColor(CRGB(0, 0, 0));
+ }
+
+ Serial.begin(serialRate);
+ Serial.print("Ada\n"); // Связаться с компом
+}
+
+void loop() {
+ if (auto_bright) { // если включена адаптивная яркость
+ if (millis() - bright_timer > 500) { // каждые полсекунды
+ bright_timer = millis(); // сброить таймер
+ new_bright = map(analogRead(6), 0, 1000, min_bright, max_bright); // считать показания с фоторезистора, перевести диапазон
+ constrain(new_bright, min_bright, max_bright);
+ LEDS.setBrightness(new_bright); // установить новую яркость
+ }
+ }
+
+ for (i = 0; i < sizeof prefix; ++i) {
+waitLoop: while (!Serial.available()) ;;
+ if (prefix[i] == Serial.read()) continue;
+ i = 0;
+ goto waitLoop;
+ }
+
+ while (!Serial.available()) ;;
+ hi = Serial.read();
+ while (!Serial.available()) ;;
+ lo = Serial.read();
+ while (!Serial.available()) ;;
+ chk = Serial.read();
+ if (chk != (hi ^ lo ^ 0x55))
+ {
+ i = 0;
+ goto waitLoop;
+ }
+
+ memset(leds, 0, NUM_LEDS * sizeof(struct CRGB));
+ for (uint8_t i = 0; i < NUM_LEDS; i++) {
+ byte r, g, b;
+ // читаем данные для каждого цвета
+ while (!Serial.available());
+ r = Serial.read();
+ while (!Serial.available());
+ g = Serial.read();
+ while (!Serial.available());
+ b = Serial.read();
+ leds[i].r = r;
+ leds[i].g = g;
+ leds[i].b = b;
+ }
+ FastLED.show(); // записываем цвета в ленту
+}