Using Proximity Switches with Your Linear Actuator

Proximity Switches

Proximity switches, or sensors, are non-contact switches that can detect the presence of an object in their vicinity. These sensors can be used to tell a linear actuator to move or stop when an object is position in front of the sensor or if an object is taken away. They can also be used to determine how far away the closest object is to them and can be used to provide feedback to control the linear actuator. Commonly, you will see proximity sensors used with hands-free or touchless devices, like in touchless hand dryer and hands-free powered tailgates in SUVs, but are also used in a wide range of industrial applications. For use with linear actuators, proximity sensors can be used in various situations including touchless control and object detection feedback.

Proximity sensors generally detect the presence of an object by using either electromagnetic field, light, or sound [1]. The method that your linear actuator detects whether an object is present will depend on the type of proximity sensor. There are four common types of proximity sensors:

  • Inductive:         Uses magnetic field to detect ferrous material
  • Capacitive:       Uses changes in capacitance to detect an object 
  • Photoelectric:  Uses light to detect if an object is present
  • Ultrasonic:        Uses sound to detect if an object is present 

Your choice in type will depend on your application and what material you want to detect [1]. You will also have a host of other specifications you will need to consider when choosing the right proximity sensor, which includes detection range, response time, switching frequency, operating temperature, and output signal. To choose the right proximity sensor, you’ll need to consider your application needs, the type of sensor, the above specifications, and consult the sensor’s datasheet for additional information.

Capacitive Proximity Sensor

What’s the Difference Between Proximity Sensors & Motion Detectors?

Proximity sensors are not motion detectors as they detect the proximity of an object rather than motion. Motion Detectors, as their name suggest, sense movement rather than the closeness of an object or person. Functionally, a proximity sensor will be able to tell you how close an object is to the sensor whether the object is moving or not. While motion detectors, will only trigger when there is movement regardless of how close an object is.

Motion Detector

Touchless Control

For touchless control, you will utilize the proximity sensor like a simple push button. To do this, you’ll want to pick a proximity sensor that has a shorter detection range, so you don’t accidently trigger the switch, and a sensor that will detect your hand, foot, or whatever you are trying to detect. A good option for this is a capacitive proximity sensor as they have short detection range and can detect a wide range of materials, but ultrasonic and some photoelectric proximity sensors will also work as long as they have a shorter detection range [1]. You will need to connect the proximity sensor to a microcontroller, like an Arduino, to read the output of the sensor. How you connect your proximity sensor to your microcontroller will depend on your choice of sensor, but in most cases, your microcontroller will either receive a digital converted analog value or will need to convert an analog signal to a digital value.

The proximity sensor will only act like a single push button in this application, which will limit our control over the linear actuator. Utilizing our microcontroller, we can write code to toggle between extending and retracting when the sensor is triggered and by utilizing the internal limit switches of the linear actuator to stop the actuator when it reaches either the fully extended or retracted position. We can also make use of internal feedback or external limit switches which would allow us to utilize other positions rather than fully extended or retracted, although we will still be limited to two positions. To do this in the firmware of our microcontroller, we will need to toggle a flag variable every time the proximity sensor is triggered. The code sample below shows the main loop of an Arduino IDE code using the flag sensorFlag to determine which direction to drive the linear actuator, which is driven by a motor driver.

To toggle this flag, we need to read the value of the proximity sensor. As we don’t know when the sensor will be triggered, we will either need to be constantly reading the sensor in the main loop of our code or we can make use of internal timer interrupts to read the sensor periodically. The latter is considered best practice, especially if you want to use your microcontroller to preform parallel tasks, as it ensures your sensor will always be read over the exact period of time. The code sample below, which using an Arduino, shows how to setup an internal timer interrupt that is triggered every second. For the Arduino, this is a bit more complex than external interrupts and you may need to do some additional reading to learn how to set up your interrupt for your application.

The SINGAL Function, in the code above, is the interrupt service routine for the timer interrupt, which runs every time the interrupt is triggered, updates the value from the proximity sensor every second. If the value read from the sensor is smaller than our threshold value, we consider the sensors “pressed” and toggle the sensorFlag. You will need to determine this threshold value beforehand by testing out your sensor and determine an output value that you want to consider as “pressed”. To limit the toggling of the sensorFlag to only once while the sensor is “pressed”, there is another flag that is not reset until the sensor value is no longer smaller than the threshold value.  

Obstacle Detection

Proximity sensors can also be used to measure how close the closest object in front of them is. This can be particularly useful in applications with linear actuators to detect obstacles in front of the actuator and send feedback back to the controller to stop the actuator if it comes too close to an object, like in the video below. To use a proximity sensor in a similar fashion, you’ll want to choose a proximity sensor that has a larger detection range and is able to detect various types of materials. Ultrasonic sensors are a good choice for this as they can have a wide sensing field, although you’ll need to be careful of the sensor’s blind spots.

The setup of the proximity sensor for this application is quite similar to the touchless control. You will still need to read the output of the sensor using a microcontroller and you’ll again want to make use of an internal timer interrupt to read the values from the sensor periodically. Although, the sensor will now be positioned in front of the actuator to detect obstacles in front of it. The output from the sensor will be related to the distance of the closest object in front of the sensor, which means we can determine a threshold value that is based on the minimum safe distance. This threshold value will vary based on the sensor that is selected. In the code sample below, the SIGNAL function, which is the interrupt service routine, is preformed every millisecond and measures the output of our sensor and compares it to our threshold value. If the measured value is smaller than the threshold value, the flag sensorFlag is set to 1 and is used in the main loop to stop the linear actuator. While the measured value is smaller than the threshold value, the code will not allow for the actuator to be extended any further until the measure value is larger than the threshold value and the flag is reset to 0. The code will still allow for the linear actuator to retract while the sensorFlag is set to 1 as it is still safe to retract the actuator.


[1] Kinney, T. A. (2001, Sept) Proximity Sensors Compared: Inductive, Capacitive, Photoelectric, and Ultrasonic Retrieved From:

Sensor Images from:  


Share this article

Featured Collections

Need Help Finding the Right Actuator?

We precision engineer and manufacture our products so you get direct manufacturers pricing. We offer same day shipping and knowledgeable customer support.

Give us a call or email us and we'll be happy to help you find the best actuator for your project.