- msg = LedStripe()
- msg.leds = [
- Led(4, randint(0, max_val), randint(0, max_val), randint(0, max_val)),
- Led(5, randint(0, max_val), randint(0, max_val), randint(0, max_val)),
- Led(6, randint(0, max_val), randint(0, max_val), randint(0, max_val)),
- Led(7, randint(0, max_val), randint(0, max_val), randint(0, max_val))
- ]
- pub.publish(msg)
+ if light <= ldr_thres or val != 0:
+ now = datetime.now()
+ if light <= ldr_thres and now.hour >= 18 and now.hour <= 22:
+ val = max_val
+ else:
+ val = 0
+ msg = LedStripe()
+ msg.leds = [
+ Led(4, randint(0, val), randint(0, val), randint(0, val)),
+ Led(5, randint(0, val), randint(0, val), randint(0, val)),
+ Led(6, randint(0, val), randint(0, val), randint(0, val)),
+ Led(7, randint(0, val), randint(0, val), randint(0, val))
+ ]
+ pub.publish(msg)