No video

Linear Actuator Arduino Control using L298N Motor Control Board

  Рет қаралды 44,849

Science Fun

Science Fun

Күн бұрын

Linear Actuator Arduino Control using L298N Motor Control Board
In this tutorial I will show you how to use the L298N motor control board and write simple Arduino code to control a linear actuator. The L298N is a compact and inexpensive H bridge motor control board that easily interfaces with microcontrollers such as the Arduino or Raspberry Pi. Though it costs a little more than the L9110, it is capable of much higher power and can also provide 5V for your Arduino. It is also capable of dc motor speed control.
In a previous video I used an L9110 and a magnetic proximity sensor to control an industrial linear actuator. In this video, I use an L298N with a 3 button switch to extend, retract, and stop a linear actuator. I also describe the Arduino code used to interface with the L298N. In a future video, I will use and RC transmitter and receiver to control the speed and direction of the linear actuator. Please subscribe to my channel and help me reach my goal of 1,000 subscribers by the end of 2020.
Pin Connections:
L298N 12V to Battery +
L298N GND to Battery -
L298N GND to Breadboard GND Rail
L298N 5V to Breadboard 5V Rail
L298N OUT1 to Linear Actuator +
L298N OUT1 to Linear Actuator -
L298N In1 to Arduino Pin 9
L298N In2 to Arduino Pin 10
Button Common to Breadboard GND Rail
Retract Button to Breadboard 5V through 10k resistor and to Arduino Pin 2
Extend Button to Breadboard 5V through 10k resistor and to Arduino Pin 3
Stop Button to Breadboard 5V through 10k resistor and to Arduino Pin 4
Arduino GND to Breadboard GND Rail
Arduino 5V pin to Breadboard 5V Rail

Пікірлер: 143
@73Ferret
@73Ferret 7 ай бұрын
That’s got to be the clearest presentation of this ever.
@ScienceFunInnovations
@ScienceFunInnovations 7 ай бұрын
Glad you liked it. Thanks for watching!
@m.on.a.b.
@m.on.a.b. 4 жыл бұрын
Hello Sir! Great videos that you're making! Please keep up the nice work. You helped me with the EasyDriver Stepper Control Video on a side project for my Bachelors Degree. I hope that your channel gets popular!
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
Glad I could help. Good luck with you B.S.
@michaelweatherby8648
@michaelweatherby8648 3 жыл бұрын
Thanks. I was pretty sure I knew what to do, but it's always nice to have a reference. This is exactly what I was thinking, 12V, l298n, and a limit switch. Cheers!
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Glad I could help!
@neogator26
@neogator26 3 жыл бұрын
Number 750. lol As I get more time I feel your channel will be exceedingly helpful as I learn more about Arduino's for fun projects. As for now you are being quite helpful with my principles of measurement class. :-)
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Awesome, thank you for subscribing!
@sarthakskumar6026
@sarthakskumar6026 4 жыл бұрын
That's a really good video. Keep Up the Work Sir. I'm Kinda Interested in these stuffs and look forward to your support.
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
Much appreciated!
@sarthakskumar6026
@sarthakskumar6026 4 жыл бұрын
@@ScienceFunInnovations Are you available on Instagram? If you would allow me to share your channel and let you know. I guess that would just make me a better friend of yours.
@3xAudio
@3xAudio 4 жыл бұрын
Always interesting ideas to get inspiration in the Arduino community thanks for sharing.
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
No problem 👍
@gusgtzmiranda
@gusgtzmiranda 3 жыл бұрын
Excellent code and explanaition my friend, it was really helpful. :) Keep doing this kind of videos. Greetings from Mexico
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Gracias, lo haré!
@ottolouis7653
@ottolouis7653 3 жыл бұрын
dont know if you guys cares but if you're bored like me atm you can stream all of the latest movies on instaflixxer. Have been watching with my girlfriend for the last couple of days :)
@guscarmelo9216
@guscarmelo9216 3 жыл бұрын
@Otto Louis yea, I have been watching on instaflixxer for since december myself =)
@ahmedizaiah9199
@ahmedizaiah9199 3 жыл бұрын
@Otto Louis Yea, I've been watching on instaflixxer for months myself :D
@iangreaves5457
@iangreaves5457 4 жыл бұрын
Hi, a good demonstration. A schematic for the wiring would be helpful.
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
I added a schematic to my Facebook page: kzbin.info?redir_token=02jIURwDAyLgAtjWnW65wxRyDdl8MTU4NjgzNTUyNEAxNTg2NzQ5MTI0&q=https%3A%2F%2Ffb.me%2FScienceFun4u&event=channel_description Thanks for the feedback.
@iangreaves5457
@iangreaves5457 4 жыл бұрын
That's great, thanks very much. I'll be using this in the next couple of weeks to steer a mobility scooter base via remote control -- hopefully.
@Cosmos229
@Cosmos229 3 ай бұрын
Hi, your video is so helpful for me. But I have one question. As I know, peak current of L298N is 2A. But your linear actuator's continuous current or stall current seem to exceed 2A. is it okay to use L298N?
@ScienceFunInnovations
@ScienceFunInnovations 2 ай бұрын
I would use a BTS7960 if there was any load. It is good to 43 Amps and is still affordable.
@jaandel1
@jaandel1 3 жыл бұрын
How can you input data ( measure) to extend to the right measurement e.x input 20mm the bar should increase 20mm exactly.. if you input new data they will adjust the previus measurement to the new data
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Some actuators have built in position feedback sensors that can connect straight to an Arduino. These generally cost a bit more. Other options are to use an external linear potentiometer or an ultrasonic sensor. I'm hoping to cover this topic in a future video. Thanks for watching.
@DC_ABC_123
@DC_ABC_123 4 жыл бұрын
EDIT: I Switched to my Arduino Mega and for some reaason everything works now. I'm getting frustrated here. I've been trying to measure the PWM signal from my tx input using the serial monitor. However, before I even turn on my tx, the serial monitor spits out random numbers, and when I turn the tx on, it still does the same. I double checked the code, which is exactly as you have it. I'm on pin 7, both in the sketch and on the Uno. I plugged a servo into several different channels as a test that they're working. I've tried this with my flysky fs-t6 in sticks mode as well as my tactic pistol controller. NOTHING works like it should in the video. What's going on here? I'm about ready to give up.
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
That is weird that it worked on the Mega but not the Uno. Did you have any breakthroughs on what was wrong?
@burak6871
@burak6871 4 ай бұрын
Good day. I would like to control a TGM7 series 24V 6A geared motor using a 24V DC motor controller (lithium battery) and Arduino. I would appreciate your help on this subject.
@ScienceFunInnovations
@ScienceFunInnovations 3 ай бұрын
What exactly are you needing help with? You could send an email to my business email with details.
@netsurfer2975
@netsurfer2975 3 жыл бұрын
For someone as new as I am to this I have to say you were too quick in explaining wiring and too brief in the explanation of some terms. But I do appreciate your video.
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Glad it helped. I have a few other linear actuator videos that may help fill in some of the gaps.
@hebrewhammer1000
@hebrewhammer1000 3 жыл бұрын
Thanks for sharing! Great video format and content
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Thanks for watching!
@sujitvasanth2502
@sujitvasanth2502 2 жыл бұрын
Nice video! I like that you explain everything!
@ScienceFunInnovations
@ScienceFunInnovations 2 жыл бұрын
Glad you liked it!
@user-ou6bc6ci4b
@user-ou6bc6ci4b 7 ай бұрын
thank u for cool video. i ahve a question that did you use any library manger? When I write your code, high and low couldn't be blue. Is it okay that high and low code is just normal? I hope you solve my question quickly!
@ScienceFunInnovations
@ScienceFunInnovations 7 ай бұрын
I try not to use any libraries if I can help it. Check out some of my other actuator videos to learn more.
@PreMix759
@PreMix759 3 жыл бұрын
How can I supply 12V to the linear actuator while still utilizing the Arduino? I need to establish an upper limit (extend 3.5") for the actuator and I need to supply all 12V as I will be maxing out the weight capabilities of my actuator. Its rated for 225lb with a 4" stroke, I need to lift 215lbs 3.5"
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Does you actuator have a max current rating? If it pulls more than about 3 amps at full load, you may need to use something stronger like a motor controller similar to this one ebay.to/2yrsTjn
@PreMix759
@PreMix759 3 жыл бұрын
@@ScienceFunInnovations 4.6A. I have a L298N as well
@shresthagupta7610
@shresthagupta7610 2 ай бұрын
Can we make a circuit without using buttons such that if we program it in labview, one click will push it forward and another click er take it backwards?
@ScienceFunInnovations
@ScienceFunInnovations 2 ай бұрын
Definitely yes. The button is just one easy way.
@hemayetkabir1331
@hemayetkabir1331 4 жыл бұрын
Special thanks to you.
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
Glad you liked it.
@hemayetkabir1331
@hemayetkabir1331 4 жыл бұрын
A schematic would really help. Please upload that. Thank you so much.
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
I added a schematic to my Facebook page: kzbin.info?redir_token=02jIURwDAyLgAtjWnW65wxRyDdl8MTU4NjgzNTUyNEAxNTg2NzQ5MTI0&q=https%3A%2F%2Ffb.me%2FScienceFun4u&event=channel_description Thanks for the feedback.
@darrreltrigg2282
@darrreltrigg2282 3 жыл бұрын
Thanks for the video very interesting. I am only just getting into electronics and would like to take this a step further, by being able to read an output from the linear actuator as to how far it is extended, then display this on a LCD screen and also have the ability to be able to stop the actuator in different memory positions. I want to use these to control to 600N 500mm linear actuators to make a sit stand desk.
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
I am planning on doing a video about linear actuator position control very soon. My part is scheduled to arrive from China in a week or two, then I hope to have the video out by the end of the month. Hit subscribe and turn on notifications so that you are alerted once it posts. Thanks for watching!
@raymondche3685
@raymondche3685 3 жыл бұрын
G'day mate, question, if i were to incorporate this set up for an outboard/ jet nozzel steering system, how would i be able to make the actuator finish at the centre position (self centre) when there's no input signal. thank you in advance, Raymond from Sydney.
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Great question. They do make actuators that have position feedback (usually a potentiometer) that you could feed into an Analog channel on the Arduino. Otherwise you would have to use some sort of position feedback system such as an LVDT.
@raymondche3685
@raymondche3685 3 жыл бұрын
@@ScienceFunInnovations thanks for your reply, I understand the theory, but do you reckon you could make a video on this project, also write the code for the arduino part as I am better with the building part, (not so good with the coding part) I am an electrician by trade. Thx.
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
I have had some similar requests for a video like that, so it is definitely on my to-do list. I'll have to order some parts first, but I do hope to do that video sometime in the next few months.
@croydon21H
@croydon21H 3 жыл бұрын
I thought we have to use BTS7960B 43A or similar. will L298N be enough?
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Depends on the load on the actuator and the current draw. For heavy loads, use the BTS7960B. I will be using the BTS7960B in an upcoming video.
@IainHendry
@IainHendry Жыл бұрын
What do the resistors do for the switches? What do you mean by “pull up resistors”? Can’t the switch just wire directly to the input?
@ScienceFunInnovations
@ScienceFunInnovations Жыл бұрын
There is a way to wire directly to the inputs without using pull-up or pull-down resistors if the microcontroller has resistors built in. Most of the newer Arduinos can do it without the resistors, but you may need to add a little more code. There are many articles about this if you search for it on the web. Cheers!
@tommasomarano7127
@tommasomarano7127 2 жыл бұрын
Great ones. I would like to know which is the name of the three button switch
@ScienceFunInnovations
@ScienceFunInnovations 2 жыл бұрын
It is called a membrane switch.
@richardpayne9640
@richardpayne9640 3 жыл бұрын
could you not do the same with a dpdt switch plus relays if you wanted to be easy on on the switch?
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Yes. A DPDT would work as well. The motor control board allows for variable speed control (as well as automation if sensors are used instead of buttons).
@richardpayne9640
@richardpayne9640 3 жыл бұрын
@@ScienceFunInnovations I understand actuators are pretty neat
@user-tw1ti1tr3l
@user-tw1ti1tr3l Жыл бұрын
안녕하세요 혹시 아두이노 메가로 변경하면 핀 번호가 달라져야 하나요?
@ScienceFunInnovations
@ScienceFunInnovations Жыл бұрын
Mega는 Uno와 동일한 핀을 가지고 있어야 하며 더 많은 핀이 있어야 합니다.
@charleslim4741
@charleslim4741 3 жыл бұрын
Hi great video! I am following your instructions to make my own arduino-controlled linear actuator. Quick question, is it possible to burn out the L298N by accidentally leaving the switch in extend/retract position for a few minutes and forgetting to press the stop button? (Assuming your linear actuator has an automatic cut-off function). I think I may have burnt out my L298N!
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Most actuators have automatic cut off on both ends, so that should not burn out the L298N. What could burn it out is if you actuator pulls more than 2 amps continuous or more than 3 amps momentary. Actuators under heavy force will pull more current. I may do a future video using a different motor control board that can handle more power.
@charleslim4741
@charleslim4741 3 жыл бұрын
@@ScienceFunInnovations Thanks for your reply! I figured out the issue, turns out I placed the L298N on a metal surface and the contacts on the bottom shorted out, causing the L298N to fail. Looking forward to that video!
@JohnAnderson-Catfish
@JohnAnderson-Catfish 4 жыл бұрын
Hi, great demo! I have a question, I'm using two wifi switches with my linear actuator with 4 relays, I would like to not use the relays and use something like this but with a raspberry pi or arduino. Can that be done?
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
Control will work with Rasperry Pi or Arduino, but you will need some sort of H-bridge or motor controller that is capable of handling the current of the actuator. The current can be much higher with higher loads, so you will want to make sure that the driver controlled by the Arduino can handle the load.
@JohnAnderson-Catfish
@JohnAnderson-Catfish 4 жыл бұрын
@@ScienceFunInnovations Thank you for replying, I new to both the Arduino and Raspberry, I did order an H bridge. Thanks again!
@cardude2191984
@cardude2191984 2 жыл бұрын
First I’d like to start off by saying I am a complete novice when it comes to this type of stuff. I’m wanting to put together a automatic chicken door opener. I have components from a lift chair which consist of a 24v dc linear actuator and power supply. I’m trying to figure out the best way to control this system and I’m wanting.
@ScienceFunInnovations
@ScienceFunInnovations 2 жыл бұрын
It would be similar, but you would probably want a stronger motor controller. Good luck!
@mirulzzz99
@mirulzzz99 4 жыл бұрын
hi can u help me with the circuit and code if i added hc 06 bluetooth module
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
You can send more details to my business email sciencefunbiz@gmail.com and I can see what I can do to help. Thanks for watching!
@nurjamahashiabdulle1711
@nurjamahashiabdulle1711 3 жыл бұрын
@@ScienceFunInnovations How can i control linear actuator without using these 1x3 membrane switches?
@muhammadfakhry8797
@muhammadfakhry8797 7 ай бұрын
Hello sir good day. I have a question instead of controlling the linear actuator using three buttons, how can I automatically move the linear actuator based on input data from SD card? I hope you can help me
@ScienceFunInnovations
@ScienceFunInnovations 7 ай бұрын
You would just do a read command to get the new position value, then set that to the current position as is done in some of my other actuator videos.
@muhammadfakhry8797
@muhammadfakhry8797 7 ай бұрын
can you please give the link to the video so I can refer to the video @@ScienceFunInnovations
@aminfirdaus3279
@aminfirdaus3279 Жыл бұрын
great video, i have a question, if I want to use linear actuator with encoder to control it at specific location or length, how may I know the range of it, can i use manual method by just supply power to it and read the encoder position from the beginning until the end of it?
@ScienceFunInnovations
@ScienceFunInnovations Жыл бұрын
Yes you can. Check out my more recent videos to see how to do that.
@kanhuprasadmaharana6409
@kanhuprasadmaharana6409 3 жыл бұрын
Where I got this button, please give the link
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
I get my on eBay. Here is the link ebay.to/2RXWxUk
@allenwright1592
@allenwright1592 Жыл бұрын
I am attempting to do this except using a FlySky i6x and wanting to control the actuator with the 3 position switch. I can get the actuator to extend, but not retract. I'm sure it's in the code. Thoughts?
@ScienceFunInnovations
@ScienceFunInnovations Жыл бұрын
Probably in the code. I have several videos about controlling linear actuators, hopefully one of those gives you some good ideas.
@chewchengkai2769
@chewchengkai2769 Жыл бұрын
Hello sir, want to ask how about connection two linear actuators and syncing the movement of the linear actuator?
@ScienceFunInnovations
@ScienceFunInnovations Жыл бұрын
In order to sync the positions of the actuators, you need actuators with position feedback. Some of my new videos use these 5 wire actuators. You would still want 2 seperate motor controllers but you would use the position feedback from one actuator to control the other actuator.
@Kimky265
@Kimky265 4 жыл бұрын
Thank you for your vidio, i wonder part name of the switch(?)
@Kimky265
@Kimky265 4 жыл бұрын
Please let me know !
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
It is called a 1X3 Membrane Switch. I purchased mine from Ebay ebay.to/2RXWxUk
@nurjamahashiabdulle1711
@nurjamahashiabdulle1711 3 жыл бұрын
@@ScienceFunInnovations what is the size of this I linked and saw 1*3key 36*55 mm one
@nurjamahashiabdulle1711
@nurjamahashiabdulle1711 3 жыл бұрын
@@ScienceFunInnovations is it?
@user-cr6ki4qs4y
@user-cr6ki4qs4y 4 жыл бұрын
Hi and thanks so much for this video! Is there such a way to make it so it works similar to a power window? Like hold the up button for 2 seconds and release to fully extend but make presses less than 2 seconds, a move and release? Also is it possible to make the stop button move the actuator to a specific position?
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
Yes, you could program it to be like a power window. Once the switch is pressed you record the timestamp using millis(). Then in your loop you would calculate elapsed time = millis() - timestamp. Once enough time has elapsed, you would check the switch again to set the mode to extend. Stopping in a specific position requires an actuator with a built in potentiometer (a bit more money) or an external linear position sensor. Once of these days I will do a video about it.
@itaycarpis9291
@itaycarpis9291 3 жыл бұрын
​@@ScienceFunInnovations, let's assume I have an actuator ​with a built-in potentiometer, is it possible to move the actuator to a specific position using the L298N only? or I must involve the Arduino with some code?
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
@@itaycarpis9291 You would still need some simple code to keep track of the window position. You would use an analog input to measure the potentiometer position. That way you could have it go to specific positions. I will likely do a video about this in the future.
@itaycarpis9291
@itaycarpis9291 3 жыл бұрын
​ @Science Fun , thank you for the super quick answer :) Do you know maybe if there is a motor control that does the position fix without any external involvement, such as Arduino... Some motor control that gets the feedback from a potentiometer actuator signal as an input and fixes the position according to the required position.
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
@@itaycarpis9291 There may be some that use limit switches, but I'm not sure if there are any with position control.
@user-sy5bp3mv3w
@user-sy5bp3mv3w 4 жыл бұрын
What is the name of the remote control with 3 buttons? Could you tell me the name or purchase link of that part?
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
It is called a 1X3 Membrane Switch. Here is a link ebay.to/2RXWxUk
@user-sy5bp3mv3w
@user-sy5bp3mv3w 4 жыл бұрын
@@ScienceFunInnovations thank you very much
@shahrizanf
@shahrizanf 8 ай бұрын
Hi sir , if want to make this linearmotor system to move automatically, how to do it?
@ScienceFunInnovations
@ScienceFunInnovations 8 ай бұрын
I have some other videos on my channel that do that. Check them out.
@gumuruhsspj
@gumuruhsspj Жыл бұрын
is it possible if we want to implement linear actuator for sliding a door (house) not a smaller one?
@ScienceFunInnovations
@ScienceFunInnovations Жыл бұрын
Yes. They come in all sorts of lengths.
@CzKaa
@CzKaa 3 жыл бұрын
Hmm, this basic simply code in arduino and drive have same function as only 2-pole switch with blind position in middle.... :)
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Pretty much, but you can also change the speed with this setup. Thanks for watching.
@moathnaji2763
@moathnaji2763 4 жыл бұрын
Hi …I want to control a dc motor making it rotate 10 times forward then pause for 3 seconds and rotate 10 times backward…. this rotation cycle back and forth will be repeated automatically 20 times exactly like the washing machine. What I need to do that?
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
You could do that with a stepper motor kzbin.info/www/bejne/l3zbmmp4aZKXaLc or else you would need a motor with position feedback such as an encoder.
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
Also you could use an easydriver kzbin.info/www/bejne/pJLJoHt3nd9rj9U
@parthdandawate7245
@parthdandawate7245 2 жыл бұрын
Please reply...I have a 24v 6 amp linear actuator can I use L298N Motor drive or do I need to use more powerful motor drive?
@ScienceFunInnovations
@ScienceFunInnovations 2 жыл бұрын
L298N is only good to about 3 amps. I would use a BTS7960.
@parthdandawate7245
@parthdandawate7245 2 жыл бұрын
Instead of using all these motor drives, Arduino, membrane button to control actuators, I have used DBDT (Double pole double throw) switch and I am able to control actuators.
@tawiahlot9926
@tawiahlot9926 2 жыл бұрын
Can I just use any Linear Actuator with the L298N Motor Control Board? or there are specific linear actuators?
@ScienceFunInnovations
@ScienceFunInnovations 2 жыл бұрын
The L298N is limited to about 3 amps. You may want a more heavy duty controller if you intend to have high loads/forces. But they all pretty much work the same way. Just find out how many amps the actuator uses under full load first, then select a motor control board that can handle the power draw. Cheers!
@duller9430
@duller9430 2 жыл бұрын
Is there any way of doing this without a motor driver
@ScienceFunInnovations
@ScienceFunInnovations 2 жыл бұрын
Yes. You can do it with a dpdt switch.
@WestKyCrime
@WestKyCrime 4 жыл бұрын
How do we contact you with out going to facebook? Looking to see if you would be willing to support the design for a controls system that is too long to describe here? Thanks In Advance Todd
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
I just added an email address in the "About" section on my KZbin channel. If nothing else, I could read about your idea and possibly give some suggestions.
@daffaarfnd463
@daffaarfnd463 3 жыл бұрын
hai, how to make it move automaticly? like every 3 second actuator will change direction. i need for science project, sorry for bad english hahah
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
You could set it up in a 3 second loop that alternates between extend and retract mode. Start by deleting the code related to the buttons and just use the extend and retract commands. Good luck.
@williamfrench1277
@williamfrench1277 4 жыл бұрын
I was wondering if the code was available to download?
@ScienceFunInnovations
@ScienceFunInnovations 4 жыл бұрын
Here it is: const int Retract_button = 2; const int Extend_button = 3; const int Stop_button = 4; const int Extend = 10; //Connect to L298N Pin In1 const int Retract = 9; //Connect to L298N Pin In2 void setup() { pinMode(Retract_button, INPUT); pinMode(Extend_button, INPUT); pinMode(Stop_button, INPUT); pinMode(Extend, OUTPUT); pinMode(Retract, OUTPUT); digitalWrite(Extend, LOW); digitalWrite(Retract, LOW); } void loop() { if(digitalRead(Retract_button)==LOW) { digitalWrite(Retract, HIGH); digitalWrite(Extend, LOW); } if(digitalRead(Extend_button)==LOW) { digitalWrite(Retract, LOW); digitalWrite(Extend, HIGH); } if(digitalRead(Stop_button)==LOW) { digitalWrite(Retract, LOW); digitalWrite(Extend, LOW); } delay(250); }
@nurjamahashiabdulle1711
@nurjamahashiabdulle1711 3 жыл бұрын
@@ScienceFunInnovations thanks 4 beautiful code with beautiful project 😍😍😍
@mackgonsalves8925
@mackgonsalves8925 2 жыл бұрын
Can a raspberry pi be used instead of the arduino?
@ScienceFunInnovations
@ScienceFunInnovations 2 жыл бұрын
Yes. The pi can do digital inputs and outputs, but at 3.3V instead of 5V. Most motor controllers will work with the lower voltage.
@MuhammadAwais-jh2dy
@MuhammadAwais-jh2dy Жыл бұрын
Sir why you use that white board?
@ScienceFunInnovations
@ScienceFunInnovations Жыл бұрын
I did that video a long time ago, what white board?
@MattG101680
@MattG101680 3 жыл бұрын
What is the benefit of using this board over a relay board?
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
With this board, you can adjust the speed. With a relay it is either full on or full off.
@MattG101680
@MattG101680 3 жыл бұрын
@@ScienceFunInnovations, thank you, that is great info. I have a project, that I am trying to figure out, and new to Arduino. Researching all the parts to see what is best. Im basically making power windows with auto up and down when you hit the switch. I just dont have it figured out yet, then I want to update the switch to a GPS module so the motor would run one way at a certain speed and the other at a certain speed. Its for a retractable rear spoiler on a car.
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
@@MattG101680 The are GPS modules compatible with Arduino. You would probably need to convert the speed text string from the GPS into a number on the Arduino and then just run a simple if statement. You also may want to add a time condition so that it doesn't keep going up and down if you are cruising right at the trigger speed. Good luck!
@MattG101680
@MattG101680 3 жыл бұрын
@@ScienceFunInnovations, thats kind of what I was thinking, I thought id make it go down at 25 and up at 30. I have the GPS module on order, I thought maybe getting it set up by switch first is smart and then switch it to the GPS as the switch
@sammoore9689
@sammoore9689 3 жыл бұрын
Did u upload your code anywhere?
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
Sorry, I can't seem to find it for that one.
@teddyruxpin3811
@teddyruxpin3811 2 жыл бұрын
Thanks but it would be nice if you put the code on github and put a link in the description or us
@ScienceFunInnovations
@ScienceFunInnovations 2 жыл бұрын
I don't have that code anymore, but from now on I will be posting much of my codes.
@teddyruxpin3811
@teddyruxpin3811 2 жыл бұрын
@@ScienceFunInnovations thanks. And thanks for the video. I got my first linear actuator working thanks to you
@alicehenderson5445
@alicehenderson5445 3 жыл бұрын
Code isn't working
@ScienceFunInnovations
@ScienceFunInnovations 3 жыл бұрын
What error are you getting?
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 32 МЛН
لقد سرقت حلوى القطن بشكل خفي لأصنع مصاصة🤫😎
00:33
Cool Tool SHORTS Arabic
Рет қаралды 30 МЛН
Linear Actuators 101
19:44
Robert Cowan
Рет қаралды 775 М.
Driving DC Motors with Microcontrollers
1:04:32
DroneBot Workshop
Рет қаралды 629 М.
Controlling DC Motors with the L298N H Bridge and Arduino
36:41
DroneBot Workshop
Рет қаралды 1,3 МЛН
3D Printed Linear Actuator??? Surprisingly Strong!
9:36
Michael Rechtin
Рет қаралды 548 М.
How to control Actuator using Arduino - Robojax
24:15
Robojax
Рет қаралды 36 М.
Linear Actuators 101 - for Woodworkers
15:32
Tommy Tompkins
Рет қаралды 830 М.
Comparing Linear Servos & Linear Actuators - with Kyle and Jason
11:30
Hacking a weird TV censoring device
20:59
Ben Eater
Рет қаралды 3 МЛН
Linear actuator position controller from Shift Automation
4:26
Shift Automation
Рет қаралды 23 М.
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 32 МЛН