Stepper motor ESPHome using global int

Hi All,

I’m trying to work out how to right the code to set the target using a global variable value.

Below is the type of example i want to use but instead of 250 I want the value of a global, I have tried (id(global_var).value) and other things like this with no luck, is anyone able to help?

// Argument is integer (signed int)
// Set the (absolute) target position to 250 steps
id(my_stepper).set_target(250);

LOL I figured it out! so simple, I feel like an idiot

id(my_stepper).set_target(id(global_var));

I simply forgot the second bracket…

1 Like