In this lesson we explore how to control the speed and direction of a DC motor using two buttons. We are using the L293D motor controller and a small DC motor for demonstration purposes. We are using parts from our Elegoo Super Stater Kit, which you can get HERE. The basic circuit was explained in Lesson 37, and we are using that work as a starting point. The schematic below will get you started in connecting your circuit. Be sure and connect one of the Arduino ground pins to the ground rail in the second to the bottom row in the diagram below. It is good practice to connect all your grounds together.
The code we developed in the video lesson is shown below for your convenience.
Lesson 37 and 38 showed some preliminary concepts in controlling a DC motor using an arduino and the L293D motor controller. In the video above we show how to control the speed and direction of a simple DC motor using a joystick. In the neutral position, the motor is stationary. Then the speed smoothly increases as you move the joystick forward, until you reach maximum speed.
Lesson 37 and 38 showed some preliminary concepts in controlling a DC motor using an arduino and the L293D motor controller. In the video above we show how to control the speed and direction of a simple DC motor using a joystick. In the neutral position, the motor is stationary. Then the speed smoothly increases as you move the joystick forward, until you reach maximum speed. Similarly, in pulling the joystick back from the neutral position, the motor gradually increases speed in the reverse direction. The diagram below shows the basic motor control schematic we are working from.
In the circuit diagram above, we also add a wire to connect the arduino ground to the power supply ground. It is always good to have all components connected to a common ground rail. Of course, you also need to add the joystick controller as shown in the video.
In this lesson we explore how to add a tilt cutoff to our DC motor project. In many cases, you may want to automatically turn your motors off in the case where your project or robot tips over. The tilt switch is a simple way to do this. The video below takes you through the process step-by-step.
If you need help hooking the circuit up, the diagram below shows you a schematic of what we are working with. All these components are part of our ELEGOO Super Starter Kit.
In addition, you will need to add the tilt switch, as shown in the video.
Below is the code we used, with the tilt switch connected to pin 2 on the arduino.
In this lesson we learn the ins and outs of controlling a DC Motor from an Arduino. A key aspect of this is to understand you must not connect a motor directly to an arduino. You need to either build a suitable transistor and diode circuit, or you need to utilize a motor controller, such as the L293D motor control chip.
The video below explains how to hook things up and how the code works. You must always be mindful that you are using a motor with current requirements that are consistent with the motor controller and power supply you are working with. Failure to do so could result in damage to components or injury.
The circuit used in this video tutorial is shown below:
It is a good practice to have all grounds connected in a circuit, so I would connect an arduino ground to the ground rail of the breadboard. The components used in this project are from the Elegoo starter kit, which you can pick up HERE. The code is described in the video, but if you need help, this is the code we used in the lesson.
// put your setup code here, to run once:
// put your main code here, to run repeatedly:
Making The World a Better Place One High Tech Project at a Time. Enjoy!