Format Blinky Eyes
MODIFY
Trinket_Gemma_Blinky_Eyes/Trinket_Gemma_Blinky_Eyes.py
Trinket_Gemma_Blinky_Eyes/Trinket_Gemma_Blinky_Eyes.py
-# Name: Blinking Eyes - based on code by Brad Blumenthal, MAKE Magazine
-# License: GPLv3
-# 2013 - Adafruit Learning System - Modified for 8 MHz ATTiny85 and low light photocell
-# 2018 - Adafruit Learning System - Modified for Gemma M0 and Circuit Python
+"""
+Blinking Eyes - based on code by Brad Blumenthal, MAKE Magazine
+License: GPLv3
+"""
-import board
-import analogio
import time
+
+import analogio
+import board
import pulseio
try:
@@ -36,16 +37,16 @@ blink_freq_max = 6
while True:
# turn on LEDs if it is dark out
- if ( photocell.value < darkness_max ):
+ if photocell.value < darkness_max:
# blink frequency and timer
- if ( blink_delay ):
+ if blink_delay:
blink_delay = False
blink_timer_start = time.monotonic()
blink_freq = random.randint(blink_freq_min, blink_freq_max)
# time to blink? Blink once every 3 - 6 seconds (random assingment)
- if ( ( time.monotonic() - blink_timer_start ) >= blink_freq ):
+ if (time.monotonic() - blink_timer_start) >= blink_freq:
blink_delay = True
pwm.duty_cycle = 0
time.sleep(.1)
@@ -57,10 +58,10 @@ while True:
brightness = brightness + fade_amount
# reverse the direction of the fading at the ends of the fade:
- if ( brightness <= 0 ):
+ if brightness <= 0:
fade_amount = -fade_amount
counter += 1
- elif ( brightness >= 65535 ):
+ elif brightness >= 65535:
fade_amount = -fade_amount
counter += 1

Format Blinky Eyes