Hello, I'm new to microcontroller programming, I'm writing a firmware for a smart fan,
I will use raspberry pi pico
I have this pseudocode
1 How do I track the button click if we are in the wind_simulation function and waiting there in the sleep() function?
2 How do I track the button click if we are in a child infinite loop, like in the wind_simulation function?
I will use raspberry pi pico
I have this pseudocode
Code:
WEAK = 256 # 25% duty cycleMEDIUM = 512 # 50% duty cycleSTRONG = 1023 # 100% duty cycledef set_fan_speed(speed): fan.duty_u16(speed)def weak_mode(): set_fan_speed(WEAK)def medium_mode(): set_fan_speed(MEDIUM)def strong_mode(): set_fan_speed(STRONG)def wind_simulation(): while True: set_fan_speed(WEAK) time.sleep(8) set_fan_speed(MEDIUM) time.sleep(8) set_fan_speed(STRONG) time.sleep(8)# Main loopwhile True: user_input = get_user_button_clicks() if user_input == 1 weak_mode() elif user_input == 2: medium_mode() elif user_input ==3: strong_mode() elif user_input == 4: wind_simulation() else: print("Invalid mode. Please try again.")
2 How do I track the button click if we are in a child infinite loop, like in the wind_simulation function?
Statistics: Posted by Vladimir93 — Thu Aug 01, 2024 5:47 pm