How to control Actuator using Arduino and two push buttons
How to control Actuator using Arduino
This video shows how to control Actuator with 2 relay and Arduino. We have got 2 push button one is used for Push and the end one is used to pull the actuator. This project can work with virtually with any actuator and with any voltage. Any Arduino module can be used.
List of Components for this project
- Actuator which depends on power and lenght you choose
- Dual Channel (two channel) relay module
- DC power supply 12V 500mA to 1000mA (or 1A). Or use a 12V Battery or 3S Lipo Battery
Purchase items from Affiliated Stores
- Actuator from Amazon USA
- Actuator from Amazon Canada
- Actuator from all other Amazon
- Actuator from all from AliExpress
- Actuator from all from AliExpress(another)
- two Actuators with wireless Control from AliExpress
- ---
- Dual Channel Relay (Amazon USA)
- Dual Channel Relay (Amazon Canada)
- Dual Channel Relay (all other Amazon)
- Dual Channel Relay (banggood)
Code Controllign Actuator using Arduino
/*
* Arduino Code to control DC Actuator using Arduino
*
* This is basic code. I have advanced code which can be used in both
* for Low-level trigger and High-lever trigger relay with clean code
*
* Written by Ahmad Shamshiri for Robojax.com on
* Friday Jan 03, 2019
* at 17:37 in Ajax, Ontario, Canada
* Watch video instruction for this code: https://youtu.be/EaoB6lfnS7g
*
*
*
Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in structured course with all material, wiring diagram and library
all in once place. Purchase My course on Udemy.com http://robojax.com/L/?id=62
If you found this tutorial helpful, please support me so I can continue creating
content like this. You can support me on Patreon http://robojax.com/L/?id=63
or make donation using PayPal http://robojax.com/L/?id=64
*
* This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been download from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const int relay1 = 2;
const int relay2 = 3;
const int pushButton1=8;
const int pushButton2=9;
void actuatorPull();
void actuatorPush();
void turnOFF();
void setup() {
// Robojax Actuator code https://youtu.be/_bkNOyPElOo
pinMode(relay1, OUTPUT);// set pin as output for relay 1
pinMode(relay2, OUTPUT);// set pin as output for relay 2
pinMode(pushButton1, INPUT_PULLUP);
pinMode(pushButton2, INPUT_PULLUP);
// keep the motor off by keeping both HIGH
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
Serial.begin(9600);// initialize serial monitor with 9600 baud
Serial.println("Robojax Actuator Control");
Serial.println("Using 2 Relays");
delay(2000);
}
void loop() {
// Robojax Actuator code https://youtu.be/_bkNOyPElOo
while(digitalRead(pushButton1) ==LOW)
{
actuatorPull();
}
while(digitalRead(pushButton2) ==LOW)
{
actuatorPush();
}
turnOFF();
}// loop end
/*
* pushes the actuator
* written by Ahmad Shamshiri
* www.Robojax.com
* Written on Jan 03, 2019 in Ajax, Ontario, Canada
*/
void actuatorPush()
{
// Robojax Actuator code https://youtu.be/_bkNOyPElOo
digitalWrite(relay1, LOW);// turn relay 1 ON
digitalWrite(relay2, HIGH);// turn relay 2 OFF
}//actuatorPush()
/*
* pushes the actuator
* written by Ahmad Shamshiri
* www.Robojax.com
* Written on Jan 03, 2019 in Ajax, Ontario, Canada
*/
void actuatorPull()
{
// Robojax Actuator code https://youtu.be/_bkNOyPElOo
digitalWrite(relay1, HIGH);// turn relay 1 OFF
digitalWrite(relay2, LOW);// turn relay 2 ON
}//actuatorPull()
/*
* turnOFF the actuator
* written by Ahmad Shamshiri
* www.Robojax.com
* Written on Jan 03, 2019 in Ajax, Ontario, Canada
*/
void turnOFF()
{
// Robojax Actuator code https://youtu.be/_bkNOyPElOo
digitalWrite(relay1, HIGH);// turn relay 1 OFF
digitalWrite(relay2, HIGH);// turn relay 2 OFF
}//turnOFF()