Going through resources such as several things at the same time and with some greatly appreciated assistance on here I'm finally getting a grasp on how to multitask a microcontroller.
Most examples use the millis() approach to nonblocking programming. However, even in the link above the button state is being polled every loop (from what I understood).
So what confuses me is: is it bad practice to write functions, which poll sensor(s) and input(s) without timing constraints, i.e. at every iteration of loop?
Is this still consider nonblocking programming?
I've written some mock code to better illustrate what I mean. Thank you very much for reading through.
void loop() {
Button();
Sensor();
LED();
// ...
}
void Button() {
// Read button(s)
button_state = digitalRead(button_pin);
if (button_state == LOW) {
// ...
};
};
void Sensor() {
// Read sensor
int sensor_state = analogRead(sensor_pin);
if (sensor_state >= 150) {
// ...
};
};