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>2018-02-26 22:17:48 +0300
committerAlex <beragumbo@ya.ru>2018-02-26 22:17:48 +0300
commit934d4e2acc8afbfe33ca9370c836c81ed89865eb (patch)
tree91fe5c66774106941b0959f0ac58083a26860051
parentb9ccb3dfb8a2d4fd47e3d5708a4ec656568fa16f (diff)
upd
-rw-r--r--Gyver_Ambilight/Gyver_Ambilight.ino6
1 files changed, 4 insertions, 2 deletions
diff --git a/Gyver_Ambilight/Gyver_Ambilight.ino b/Gyver_Ambilight/Gyver_Ambilight.ino
index d83b7bb..475a6e1 100644
--- a/Gyver_Ambilight/Gyver_Ambilight.ino
+++ b/Gyver_Ambilight/Gyver_Ambilight.ino
@@ -13,10 +13,11 @@
#define max_bright 255 // максимальная яркость (0 - 255)
#define min_bright 50 // минимальная яркость (0 - 255)
#define bright_constant 500 // константа усиления от внешнего света (0 - 1023)
+#define bright_coef 0.01
// чем МЕНЬШЕ константа, тем "резче" будет прибавляться яркость
//----------------------НАСТРОЙКИ-----------------------
-int new_bright;
+int new_bright, new_bright_f;
unsigned long bright_timer;
#define serialRate 115200 // скорость связи с ПК
uint8_t prefix[] = {'A', 'd', 'a'}, hi, lo, chk, i; // кодовое слово Ada для связи
@@ -48,7 +49,8 @@ void loop() {
bright_timer = millis(); // сброить таймер
new_bright = map(analogRead(6), 0, bright_constant, min_bright, max_bright); // считать показания с фоторезистора, перевести диапазон
new_bright = constrain(new_bright, min_bright, max_bright);
- LEDS.setBrightness(new_bright); // установить новую яркость
+ new_bright_f = new_bright_f * bright_coef + new_bright * (1 - bright_coef);
+ LEDS.setBrightness(new_bright_f); // установить новую яркость
}
}