# Push button for Firgelli linear actuator

**URL:** <https://forum.arduino.cc/t/push-button-for-firgelli-linear-actuator/379690>\
**Category:** Motors, Mechanics, Power and CNC\
**Created:** [April 14, 2016, 6:17pm UTC](https://forum.arduino.cc/t/push-button-for-firgelli-linear-actuator/379690 "2016-04-14T18:17:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dar\_T](https://avatars.discourse-cdn.com/v4/letter/d/9de0a6/32.png) [@Dar\_T](https://forum.arduino.cc/u/Dar_T)\
**Post date:** [April 14, 2016, 6:17pm UTC](https://forum.arduino.cc/t/push-button-for-firgelli-linear-actuator/379690/1 "2016-04-14T18:17:16Z")

</div>

I'm using a Firgelli micro linear actuator ([http://learn.robotgeek.com/demo-code/119-arduino-linear-actuator-tutorial-button-control-of-a-small-linear-actuator.html](http://learn.robotgeek.com/demo-code/119-arduino-linear-actuator-tutorial-button-control-of-a-small-linear-actuator.html)). I'm trying to get my code so that when you press a button the actuator will increase to a set length and stay there until the button is pressed again. Right now, I can get the button to register an action but once in a while the actuator will just activate by itself, moving up and down with no input. I'm not sure why it's doing this.

```cpp
//Includes
#include <Servo.h> 

//Defines

#define LINEAR50PIN 9        //Linear Actuator Digital Pin

#define KNOB_PIN 0      //knob Analog Pin

//max/min pulse values in microseconds for the linear actuators

#define LINEAR50_MIN  1800    //
#define LINEAR50_MAX  1200    //

Servo LINEAR50;  // create servo objects to control the linear actuators
int knobValue;  //variables to hold the last reading from the analog pins

int linear50Value = 180;  //current positional value being sent to the linear actuator. 

int speed = 10;

void setup() 
{ 
  //initialize servos
 
  LINEAR50.attach(LINEAR50PIN, LINEAR50_MIN, LINEAR50_MAX);  // attaches/activates the linear actuator as a servo object 

  //Analog pins do not need to be initialized
  
  //use the writeMicroseconds to set the linear actuators to their default positions

  LINEAR50.writeMicroseconds(linear50Value);
} 

void loop() 
{ 

  / **************linear actuator Positions******************************* /
  //read the values from the analog sensors
  knobValue = analogRead(KNOB_PIN);

 
  linear50Value = map(knobValue, 0, 1023, LINEAR50_MAX, LINEAR50_MIN); //Map analog value from the sensor to the linear actuator
 
  //use the writeMicroseconds to set the servos to their new positions

  LINEAR50.writeMicroseconds(linear50Value);
}

```

---

<div class="post-metadata">

**Author:** ![Dar\_T](https://avatars.discourse-cdn.com/v4/letter/d/9de0a6/32.png) [@Dar\_T](https://forum.arduino.cc/u/Dar_T)\
**Post date:** [April 14, 2016, 8:32pm UTC](https://forum.arduino.cc/t/push-button-for-firgelli-linear-actuator/379690/2 "2016-04-14T20:32:21Z")

</div>

Found out I needed a pull down resistor. [arduino uno - Why does my servo twitch and turn on its own? - Arduino Stack Exchange](http://arduino.stackexchange.com/questions/8898/why-does-my-servo-twitch-and-turn-on-its-own)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 9:42am UTC](https://forum.arduino.cc/t/push-button-for-firgelli-linear-actuator/379690/3 "2021-05-06T09:42:26Z")

</div>


