diff --git a/firmware/applications/default.c b/firmware/applications/default.c
index 2e41ac6..8892ba2 100644
--- a/firmware/applications/default.c
+++ b/firmware/applications/default.c
@@ -115,8 +115,15 @@ void tick_default(void) {
     ctr++;
     if(ctr>100){
         VoltageCheck();
+        LightCheck();
         ctr=0;
     };
+
+    if(isNight())
+        backlightSetBrightness(100);
+    else
+        backlightSetBrightness(0);
+
     if(ctr%5==0){
 
         if(GetVoltage()<3600
diff --git a/firmware/basic/Makefile b/firmware/basic/Makefile
index 7bbd1bb..b5081fd 100644
--- a/firmware/basic/Makefile
+++ b/firmware/basic/Makefile
@@ -8,6 +8,7 @@ OBJS += basic.o
 OBJS += reinvoke_isp.o
 OBJS += delayms.o
 OBJS += voltage.o
+OBJS += night.o
 OBJS += keyin.o
 OBJS += uuid.o
 OBJS += crc.o
diff --git a/firmware/basic/basic.h b/firmware/basic/basic.h
index 8c6f5d0..3292ba3 100644
--- a/firmware/basic/basic.h
+++ b/firmware/basic/basic.h
@@ -135,6 +135,11 @@ void delayms(uint32_t ms);
 void VoltageCheck(void);
 uint32_t GetVoltage(void);
 
+// night.c
+void LightCheck(void);
+uint32_t GetLight(void);
+char isNight(void);
+
 // keyin.c
 #define BTN_NONE 0
 #define BTN_UP   (1<<0)
diff --git a/firmware/basic/night.c b/firmware/basic/night.c
new file mode 100644
index 0000000..8e7e60f
--- /dev/null
+++ b/firmware/basic/night.c
@@ -0,0 +1,47 @@
+#include <sysinit.h>
+
+#include "basic/basic.h"
+
+#define RANGE (10)
+#define HYST (4)
+uint32_t light=300*HYST;
+char _isnight=1;
+
+void LightCheck(void){
+    int iocon;
+    char iodir;
+
+    int value;
+
+    iocon=IOCON_PIO1_11;
+//    iodir=gpioGetDir(RB_LED3);
+    iodir= (GPIO_GPIO1DIR & (1 << (RB_LED3) ))?1:0;
+
+    gpioSetDir(RB_LED3, gpioDirection_Input);
+    IOCON_PIO1_11 = IOCON_PIO1_11_FUNC_AD7|IOCON_PIO1_11_ADMODE_ANALOG;
+    light-=light/HYST;
+	light += adcRead(7);
+    
+    gpioSetDir(RB_LED3, iodir);
+    IOCON_PIO1_11=iocon;
+
+    static uint16_t threshold=0;
+    if(threshold==0){
+        // read threshold from config
+        threshold=320 * HYST;
+    };
+
+    if(_isnight && light>(threshold+RANGE*HYST))
+        _isnight=0;
+
+    if(!_isnight && light<threshold)
+        _isnight=1;
+};
+
+uint32_t GetLight(void){
+    return light/HYST;
+};
+
+char isNight(void){
+    return _isnight;
+};