Hey brother love, I like the cut of your jib. Gimme a hot minute to dig up what you need. You'll need a relay board, a linear actuator is just a motor that spins in one direction until it hits its internal limit switch then stops, then all you have to do is reverse the direction after some time delay.
...Ok, I found the chest (my avatar pic) motor controller using a linear actuator. It's an Arduino that receives chars from another Arduino and does the deed.
Replace the char stuff with your button press. Any questions, shoot. I always gots time for fellow Halloweiners. Key thing to know though is precisely how long your actuator takes to reach its full travel distance. There's a comment in the code that follows to that effect.
char rxChar;
boolean newData = false;
char trashChar = ';';
const int forwards = 7;
const int backwards = 6;
const int readyLed = LED_BUILTIN;
void setup() {
pinMode(forwards, OUTPUT);//set relay as an output
pinMode(backwards, OUTPUT);//set relay as an output
pinMode(readyLed, OUTPUT);
digitalWrite(readyLed, LOW);
Serial.begin(115200);
}
void loop() {
recvOneChar();
showNewData();
switch (rxChar) {
/************ full open-hold(some duration)-close functions ******/
case ('b'):
normalLong();
break;
case ('o'):
normal();
break;
case ('p'):
halfShort();
break;
case ('u'):
halfMilli();
break;
case ('v'):
quarterShort();
break;
case ('w'):
quarterMilli();
break;
case ('x'):
eightShort();
break;
case ('y'):
eightTiny();
break;
case ('z'):
eightTease();
break;
/************ end full functions ***********************************/
/************ core functions/discrete operations ********************/
case ('s'):
stopAct();
break;
case ('h'):
holdAct();
break;
case ('f'):
fullExtend();
break;
case ('e'):
extend();
break;
case ('a'):
halfE();
break;
case ('t'):
quarterE();
break;
case ('c'):
fullRetract();
break;
case ('r'):
retract();
break;
case ('l'):
halfR();
case ('d'):
quarterR();
break;
case ('k'):
holdLong();
break;
}
/******************** end discrete operations ************************/
/******************** end switch/case *********************************/
digitalWrite(readyLed, LOW);
rxChar = trashChar;
}
/******************** end void loop(){} *******************************/
void recvOneChar() {
if (Serial.available() > 0) {
rxChar = Serial.read();
newData = true;
}
}
void showNewData() {
if (newData == true) {
newData = false;
}
}
/************************** COMBINED FUNCTIONS *********************/
void normalLong() { // 1 minute
extend();
holdLong();
retract();
}
void normal() { // hold 30 sec
extend();
holdAct();
retract();
}
void halfShort() { // hold 3 sec
halfE();
stopAct();
halfR();
}
void halfMilli() { // hold 1.6
halfE();
milliStop();
halfR();
}
void quarterShort() { // hold 3
quarterE();
stopAct();
quarterR();
}
void quarterMilli() { // hold 1.6
quarterE();
milliStop();
quarterR();
}
void eightShort() { // hold 3
eightOpen();
stopAct();
eightClose();
}
void eightTiny() { // hold 1.6
eightOpen();
milliStop();
eightClose();
}
void eightTease() { // hold 0.8
eightOpen();
microStop();
eightClose();
}
/************************** DISCRETE FUNCTIONS *******************************
Activate the relay one direction, they must be different to move the motor
this particular actuator takes 20 seconds each way */
/************************* OPENING FUNCTIONS *********************************/
void fullExtend() {
digitalWrite(backwards, HIGH);
digitalWrite(forwards, LOW);
digitalWrite(readyLed, HIGH);
delay(22000);
}
void extend() {
digitalWrite(backwards, HIGH);
digitalWrite(forwards, LOW);
digitalWrite(readyLed, HIGH);
delay(20000);
}
void halfE() {
digitalWrite(backwards, HIGH);
digitalWrite(forwards, LOW);
digitalWrite(readyLed, HIGH);
delay(10000);
}
void quarterE() {
digitalWrite(backwards, HIGH);
digitalWrite(forwards, LOW);
digitalWrite(readyLed, HIGH);
delay(5000);
}
void eightOpen() {
digitalWrite(backwards, HIGH);
digitalWrite(forwards, LOW);
digitalWrite(readyLed, HIGH);
delay(2500);
}
/************************** CLOSING FUNCTIONS *************************************/
void fullRetract() {
digitalWrite(backwards, LOW);
digitalWrite(forwards, HIGH);
digitalWrite(readyLed, HIGH);
delay(22000);
}
void retract() {
digitalWrite(backwards, LOW);
digitalWrite(forwards, HIGH);
digitalWrite(readyLed, HIGH);
delay(20000);
}
void halfR() {
digitalWrite(backwards, LOW);
digitalWrite(forwards, HIGH);
digitalWrite(readyLed, HIGH);
delay(10500);
}
void quarterR() {
digitalWrite(backwards, LOW);
digitalWrite(forwards, HIGH);
digitalWrite(readyLed, HIGH);
delay(5500);
}
void eightClose() {
digitalWrite(backwards, LOW);
digitalWrite(forwards, HIGH);
digitalWrite(readyLed, HIGH);
delay(2500);
}
/******************************** STOP/HOLD FUNCTIONS ********************************/
void stopAct() {
digitalWrite(forwards, HIGH);
digitalWrite(backwards, HIGH);//Deactivate both relays to brake the motor
digitalWrite(readyLed, HIGH);
delay(3000);
}
void milliStop() {
digitalWrite(forwards, HIGH);
digitalWrite(backwards, HIGH);//Deactivate both relays to brake the motor
digitalWrite(readyLed, HIGH);
delay(1600);
}
void microStop() {
digitalWrite(forwards, HIGH);
digitalWrite(backwards, HIGH);//Deactivate both relays to brake the motor
digitalWrite(readyLed, HIGH);
delay(800);
}
void holdAct() {
digitalWrite(forwards, HIGH);
digitalWrite(backwards, HIGH);//Deactivate both relays to brake the motor
digitalWrite(readyLed, HIGH);
delay(30000);
}
void holdLong() {
digitalWrite(forwards, HIGH);
digitalWrite(backwards, HIGH);//Deactivate both relays to brake the motor
digitalWrite(readyLed, HIGH);
delay(60000);
}
For those about to build, I salute you! 