Introduction: Light Follower, Also Avoids Obstacles...and Even Talks!!!
Hi guys! this is my first instructable, so I am really excited and I hope you will enjoy it!
I have been working on this project for some time, on and off, but finally I got there. This robot is a remarkable light seeker , and it is excellent for avoiding obstacles. Additionally, every time it runs into an obstacle it warns you: "watch out, obstacle!" isn´t that really cool?
Step 1: Parts
- Arduino Nano. This will be the microcontroller I will be using for this project. It´s smaller than Arduino Uno or Mega. It has fewer pins than Mega but the same pins as Uno, and anyway we will not be using all of them. And best of all, Arduino Nano draws just 19 mA in comparison to Arduino Uno (46mA) Due (75mA) or Mega (93mA). When you are running a project like this, consumption is a key point and I went in for Nano. I learned a lot about consumption here: https://www.open-electronics.org/the-power-of-arduino-this-unknown/. You can take a look if you want to!
- Servo 9G SG90. This is the servo motor which Cutebot uses to rotate its "eyes" (i.e. the Acoustic Sensor HC-SR04 that is down in the list. It works at 5V. It consumes 17mA while sleeping, 120-130mA while turning left/right.
- Acoustic Sensor HC-SR04. Cutebot´s eyes. With this sensor Cutebot will measure (by using ultrasonic pulses) the distance to any object within range. It works at 5V consuming around 15mA while working, and only around 2mA while sleeping.
- 2 LDR. Light Dependent Resistors. We need them to control the incoming light from left/right, so that our robot can decide its direction. When the intensity of light is very high, the value of this resistor goes down to a few ohms; but when the intensity goes down its resistance goes up to 10Mohms approximately, or even higher. The exact values will depend on your specific LDR, and almost any LDR will be suitable for this project. Each LDR will be in series with a 10Kohm resistor (also down in the list) to build a voltage divider.Consumption of the voltage divider is hardly 0.5mA-1mA at most.
- 2 10KOhm resistors. (as a part of the voltage divider)
- Speaker 3W 4 Ohms. Arduino is capable of giving 5V-40mA at any pin. Knowing Power=VoltagexIntensity means arduino can give you 0.2W at most. Since the speaker needs 3W we need to come up with some solution. I ended up including in my setup a relay module (down in the list) with a second dedicated battery just for this speaker. I suppose there must be a better way using a kind of amplifier...but I had that simple relay at hand and it worked. This speaker works fine at 5V. I found somewhere that this type of speaker draws around 500mA. Thats why you need a dedicated battery just for it. But I checked the real value with my polymeter and it is around 250mA, and its is just a peak of 2-3 seconds while it is working. The rest of the time it is consuming hardly 0mA.
- 1 channel relay module.
- GPD2846A TF Card MP3 Decoder Board. This component is easy to find in Aliexpress, but when you receive it...well, let us say it can be difficult to use if you don´t find a suitable datasheet. Luckily I found this youtube video with very clear and detailed information:
- Motor Controller H-Bridge L298N. You can find out about this controller in several places, this one for example was good for me: https://www.instructables.com/id/Control-DC-and-st... We use this controller because DC motors are drawing too much current and Arduino can´t handle it. I measured around 200-300mA depending on conditions (Controller+2 DC Motors). I suspect it can get even higher. In addition, and thanks to this controller, you can also make your motors spin clockwise/anticlockwise, and freely set the speed you need. It is very useful in this proyect, because turning our cutebot left/right implies transmitting different velocities to each wheel.
- 2 DC Motors + Wheels.
- 9V battery or 11.2 LIPO battery (I initially used 2x4.5V 3R12 batteries, because this type of battery supplies you a high capacity (mAh) ; then I changed to a 11.2V LIPO rechargable battery. Both options are great, but you can try your own setup (6x1.5V AA batteries for example)
- 6V holder + 6x1.5AA batteries. This is a second battery that I need to make my mp3+loudspeaker work.
- Terminal strip. You can buy something like this, then cut it. We will need 2 pieces, 4 sockets in each:
- Stranded and/or solid core wireJumper wires (Male-Male & Male-Female).
- 1 small breadboard.
- 1 terminal adapter board for Arduino Nano (you can use a breadboard instead). I used it so as to give my cutebot a better look, but also to connect the wires permanently. I don´t like searching a good socket for any loose end of any wire...
- 1 or 2 platforms for your car (you can either make your own or buy a robot chassis). Advice: let your imagination run wild!
Step 2: Setup
I draw this for you (I used Fritzing). It is easy to use if you have a lucky day and you find the components...otherwise it can be frustrating. Anyway, and after spending a long time to it, I got there.
For technical reasons, I coudn´t include my MP3 encoder in Fritzing (basically I couldn´t find it) so I took a different one (in red in the scheme) . In addition, I eventually used a 11.2V lipo battery instead of the 9V´s in my drawing (but it will work with both of them, depending on what you have at home). I zoomed in the mp3 decoder zone changing the labels to make it match with the labels in my GPD2846A TF Card MP3 Decoder Board.
Hopefully this scheme + comments will be enough for you!
Step 3: The Code
I attach the code, hope it will be useful!!!
We have a be nice policy.
Please be positive and constructive.