added button top 3d model and buzzer to code
This commit is contained in:
parent
91739586d0
commit
7c871a3b5c
BIN
HW/timer_button/3D/Tlacitko_top.SLDPRT
Normal file
BIN
HW/timer_button/3D/Tlacitko_top.SLDPRT
Normal file
Binary file not shown.
BIN
HW/timer_button/3D/Tlacitko_top.STL
Normal file
BIN
HW/timer_button/3D/Tlacitko_top.STL
Normal file
Binary file not shown.
@ -1 +1 @@
|
|||||||
{"hostname":"spock","username":"angoosh"}
|
{"hostname":"Oneill","username":"angoosh"}
|
@ -12,6 +12,7 @@ BRIGHTNESS = 0.2 # Adjust the brightness (0.0 - 1.0)
|
|||||||
led_strip = neopixel.NeoPixel(Pin(ws_pin), led_num)
|
led_strip = neopixel.NeoPixel(Pin(ws_pin), led_num)
|
||||||
|
|
||||||
push_button = Pin(24, Pin.IN, Pin.PULL_UP)
|
push_button = Pin(24, Pin.IN, Pin.PULL_UP)
|
||||||
|
buzzer = Pin(3, Pin.OUT)
|
||||||
|
|
||||||
pushbutton_pressed = 0
|
pushbutton_pressed = 0
|
||||||
blink_interrupted = 0
|
blink_interrupted = 0
|
||||||
@ -80,19 +81,24 @@ def blink_and_beep(times):
|
|||||||
blink_delay = 0.2
|
blink_delay = 0.2
|
||||||
|
|
||||||
#insert beep
|
#insert beep
|
||||||
|
buzzer.value(1)
|
||||||
for i in range(0, times):
|
for i in range(0, times):
|
||||||
set_neopixel_color(255, 0, 0)
|
set_neopixel_color(255, 0, 0)
|
||||||
|
buzzer.value(0)
|
||||||
time.sleep(blink_delay)
|
time.sleep(blink_delay)
|
||||||
set_neopixel_color(0, 0, 0)
|
set_neopixel_color(0, 0, 0)
|
||||||
|
buzzer.value(1)
|
||||||
time.sleep(blink_delay)
|
time.sleep(blink_delay)
|
||||||
if pushbutton_pressed == 1:
|
if pushbutton_pressed == 1:
|
||||||
pushbutton_pressed = 0
|
pushbutton_pressed = 0
|
||||||
blink_interrupted = 1
|
blink_interrupted = 1
|
||||||
i = times
|
i = times
|
||||||
|
buzzer.value(0)
|
||||||
return
|
return
|
||||||
|
buzzer.value(0)
|
||||||
|
|
||||||
ten_min_timer = 0
|
ten_min_timer = 0
|
||||||
ten_min_timer_led_index = 0
|
ten_min_timer_led_index = 11
|
||||||
def count_10_min():
|
def count_10_min():
|
||||||
global ten_min_timer, ten_min_timer_led_index, pushbutton_pressed, blink_interrupted
|
global ten_min_timer, ten_min_timer_led_index, pushbutton_pressed, blink_interrupted
|
||||||
|
|
||||||
@ -135,6 +141,15 @@ def button_callback(push_button):
|
|||||||
set_neopixel_color(0,0,0)
|
set_neopixel_color(0,0,0)
|
||||||
push_button.irq(trigger=Pin.IRQ_FALLING, handler=button_callback)
|
push_button.irq(trigger=Pin.IRQ_FALLING, handler=button_callback)
|
||||||
|
|
||||||
|
green = (0, 255, 0)
|
||||||
|
green = set_neopixel_brightness(green)
|
||||||
|
led_strip[0] = green
|
||||||
|
led_strip[2] = green
|
||||||
|
led_strip[4] = green
|
||||||
|
led_strip[6] = green
|
||||||
|
led_strip[8] = green
|
||||||
|
led_strip.write()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
count_10_min()
|
count_10_min()
|
||||||
time.sleep(1)
|
time.sleep(0.01)
|
Loading…
x
Reference in New Issue
Block a user