arduino 2 wheel robot
We are going to build an Arduino Robot that can avoid obstacles.. It is a fun project and a great learning experience, so without any further delay. Lets get started As you can see. The robot that we are going to build today is moving around and it can detect obstacles and avoid them.. It uses a ultrasonic distance sensor in order to measure the distance from its front side. When it detects and obstacle it stops, goes backward for a few cms looks around and then it turns to the direction with the more space available.. As you are going to find out building this impressive little robot is extremely easy and fun.. It will not take you more than a couple of hours from start to finish.. Then you can use my code, modify it and implement your own robot behavior easily.. It is a great learning experience and great introduction to robotics for kids and adults. Lets build it. The parts needed in order to build this robot are these: The Robot Chassis Kit, An Arduino Uno, A Motor Shield, A SG90 servo, An Ultrasonic Distance Sensor, A switch Two 100nF capacitors, 1 330F capacitor or similar Some wires. The cost of the project is around 25.. You can find links for all the parts I use in the description of the video. Before attempting to build this project. I encourage you to watch these two tutorials first.. The first one is about the servo motor and the second one is about the supersonic sensor.
. You can watch these tutorials by clicking on the card here.. First, we have to build the robot chassis.. The kit contains the chassis two motors with the wheels attached a front wheel, a battery holder, some screws and wires.. We solder the thick black and red wires at the motors.. Next, we have to solder the small ceramic capacitors to the motors.. We do so in order to reduce the electrical noise that the motor produces. Since we are using ceramic capacitors, which do not have polarity just solder, one leg to each motor, connection. Repeat the procedure with the second motor and we are ready to continue.. We then attach the front wheel.. My little nephew helps me with that. As you can see., This project is great for kids. Next, we attach the rear wheels according to the instructions leaflet that comes with kit.. The next step is to attach the switch to the battery holder.. I cut the battery holder wires and I solder the red wire from the battery holder to the first pin of the switch.. The black wire from the battery holder goes to the third pin.. Now I solder a small red wire to the middle pin of the switch.. Another small black wire is then soldered to the third pin of the switch.. Our switch is ready.. I then attach it to the battery holder using hot glue.. We move on to the motor shield.. This shield provides power to the motors and the servo motor and makes our life much easier.
. The motors need a lot of current and this shield can provide up to 600mA of current to each motor thats. Why we need it.. We have to solder 4 wires to the motor shield.. These wires will be then connected with the supersonic sensor. We solder one to 5V, one to GND, one to Analog, Pin 5 and the last one to analog pin 4.. Next, we attach the motor shield to the Arduino Uno board., With a double sided tape. I attach the Arduino Uno and the Battery holder to the chassis. With a double sided tape. I also attach the supersonic sensor to the Servo motor and both of them to the robot chassis.. I could 3D print a part in order to achieve that, but since most of the viewers dont have access to a 3D printer, yet I chose this simple solution to achieve. That. We are almost ready. All we have to do is to attach the wires First. We connect the Ultrasonic sensor. Vcc goes to 5V via the wire we attached. Earlier. GND goes to the GND wire. ECHO pin goes to Analog, Pin 5 and TRIG. Pin goes to Analog, Pin 4. Next have to connect the power.. We connect the black wire from the switch to the motor shield.. It goes to the GND pin of this external power connector., The red wire from the switch, goes to the M connector.. If we open the switch, we can see that the green LED lights up.
The Arduino is receiving power from the batteries.. The next step is to connect the motors.. We connect the left motor to the M1 connector of the shield. Like this., We connect the right motor to the M3 connector of the shield, this way.. Lastly, we have to connect the servo motor.. We connect it to the SERVO2 connector of the shield.. The Brown wire is GND, the RED is Vcc and the orange is Signal. Thats it. Our robot is now ready. All we have to do is to load the code to it. The code uses three libraries.. Two of them must be downloaded in order. The program to compile. The first one is the motor shield driver from Adafruit.. The second library is the NewPing library for the supersonic distance sensor.. You can find the links for both libraries in the description of the video. We press upload and after a few seconds the robot awakes You can watch it drive, look around and avoid the obstacles.. It is a fun little robot that you build Impressive isnt it If your robot does not drive like this check, your motor connections, again., You may have inversed polarity and one motor goes forward and the other backwards.. Another problem that it might appear is with the servo motor.. If the servo motor moves randomly or stop at some times, maybe you need to add a capacitor to it.. I had such problems with my servo motor., So I added a 330F electrolytic capacitor and the problem was solved.
. The positive leg of the capacitor goes to the RED wire and negative. The short one goes to the brown wire. Lets now take a quick look at the code in order to see how it works. At first we declare some variables. In this one. We set the speed of the motors.. You can set any value up to 255.. Next, we initialize the servo motor and we set it to look straight.. In my case, this was at 115 degrees angle.. Next we read the distance a few times in order to get a valid distance measurement.. Now we go to the loop function, which executes every 40, ms. If the distance we measured is less than or equal to 15 cm, we stop the motors, we go backwards for 300ms and then we stop again.. We look right and left and we measure the distance at each direction. If the distance at one direction is greater than the other. We turn the robot, the largest distance.. If the distance from the front of the robot is greater than 15 cm, we move the robot forward. Thats, the simple algorithm I developed for this robot, so far.. As always, you can find the code of the project in a link in the description of the video.. You can easily modify the code I provide in order to modify the robot behavior.. It is very easy., As you can see, building a robot with Arduino is very easy.. By building this project, you will understand better the Arduino board and it capabilities.
. You will learn how to control motors and how to program them.. This robot is going to be the base for many more robot projects to come.. We can add an NRF24L01 module to it to wirelessly control it and get telemetry data from it.. We can add sound lights, more sensors and better batteries.. There are a ton of improvements to be made. Thats. Why? I would love to hear your opinion on this.. What kind of features do you want to add to this simple robot? Please, post your ideas in the comments section, below. Thanks. If this is your first time here, I would love to have you subscribed. In this channel, I post videos about DIY projects every Saturday.. I love making things and I believe that anyone can make things anyone can become a maker. Thats. Why I created this channel in order to share my knowledge with the community and learn from the community.. I hope you will join us. Until next Saturday Watch Learn Build Translating these subtitles.
arduino 2 wheel robot Video
arduino 2 wheel robot news
Posted on Thursday October 03, 20193 Trends in Mobile Industrial Robotics Machine Design … Continue Reading »
Posted on Monday March 11, 2019Arduino omni-wheel robot and pen plotter Geeky Gadgets … Continue Reading »
Posted on Saturday June 03, 2017Building A Self-Balancing Robot Made Easy Hackaday … Continue Reading »
arduino 2 wheel robot Social
🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr