Motorized Linear Poti
Last updated
Was this helpful?
Last updated
Was this helpful?
We can use the to let the user control some aspect of our application using a physical control. The poti can take on values on a range between 0 and 100.
Using the , we can use simple functions to perform the most important tasks. In this article, we assume you have successfully initialized the devices with the , and you stored all connected devices on a global variable devices
. We also declared a global variable poti
.
Next, we need to know the device identifier of the Motorized Linear Poti, which is 267:
Now that we have a reference to the display on the variable poti
, we can use that variable to call the device's functions.
In a sense, the Motorized Linear Poti acts like a sensor: We can register a listener to get updates about changes to its position. We first register the listener:
In the callback function, we can distinguish between two types of updates from the device:
If we are only interested in the position of the poti, regardless of whether it was changed manually or with the motor, we can use the event type position
. If we are using the motor, as described below, and we want to know when the motor is done moving the slider, we can use the event type position_reached
. This event is only fired when the motor was used, and it has finished the move.
A nice feature of the Motorized Liner Poti is that it has a motor that lets us set the value programmatically:
The motor moves the slider, which will take a couple of milliseconds. If we want to know when the motor is done, we can check for the "position_reached" event, as described above.