Ks0441 Keyestudio Desktop Mini Bluetooth Smart Car V3.0: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
Line 1,003: Line 1,003:


<br>
<br>
===<span style="color:blue"> Project 11: Obstacle Avoiding Robot </span> ===
<br>
===<span style="color:blue"> Project 12: Line Tracking Robot </span> ===
<br>
<br>
'''Circuit Design:'''<br>
'''Circuit Design:'''<br>
We’re now ready to give the robot another capability - Obstacle Avoiding! <br>
In the above sections we already introduced the motor drive shield, sensor, module, motors and other elements.<br>
It is pretty simple. Just keep the same components and connection method as following robot, but need to change the code.<br>
According to the project 7/8 -- library driving motor, line tracking sensor,  <br>
we’re now ready to give the robot capability - Line Tracking!<br>
In the project, we make the robot detect black line at the car bottom with line tracking sensor. Then control the 2 motors rotate by measured result, so as to drive the robot track black line.<br>


<br>
<br>
'''Below is a specific logic table of following robot for reference:'''
'''Below is a specific logic table of line tracking robot for reference:'''
<br>[[File:441图120.png|700px|frameless]]<br>
<br>[[File:441图120.png|700px|frameless]]<br>



Revision as of 14:19, 13 August 2019

Keyestudio Desktop Mini Bluetooth Smart Car V3.0


Description

We can often see others on the internet making use of control boards and electrical components to build their own creative robots. Wanna DIY your own robot?
Here comes keyestudio desktop mini Bluetooth smart car V3.0, which is an upgraded version of keyestudio desktop mini Bluetooth smart car V2.0.
The smart car still keeps the functions like line tracking, obstacle avoidance, IR and Bluetooth control and more.
Furthermore, we make a great improvement for the smart car as follows:

  • 1) The Acrylic plates are more bright and colorful;
  • 2) Adding a microphone sound module to make a fantastic sound when driving the car run;
  • 3) Using Bluetooth HM-10 module,which can support Bluetooth 4.0; supporting both Android and iOS system; also can actuate the smart car with our own designed Bluetooth APP.
  • 4) Can freely choose the battery case 18650 or 4-cell AA battery case to supply power for the robot car. Note that batteries are Not Included. Users can freely choose two 18650 batteries or four AA batteries (1.5V) to supply power for the robot car.
  • 5) Making improvements on the motor drive board; one is coming with a slide switch for controlling the power switch;the other is adding 8 jumper caps to control the DC motor direction,easy for code debugging.
  • 6) Coding the robot car with Mixly blocks software, simple and ready to play.

From the basics up to complex projects, through this kit you can learn to control the robot car with Mixly blocks coding. Easy to code and learn coding and computational thinking.
If you are looking for inspiration, you can find a great variety of tutorials here. Take your brain on a fun and inspiring journey through the world of programming and electronics.


Parameters

  • 1)Motor Voltage range: 1-6V; motor shaft length: 10mm; speed: 6.0V 100rpm/min.
  • 2)Motor control is driven by L298P;
  • 3)Three groups of line tracking modules, to detect black-white line with higher accuracy and can also be used for anti-fall control;
  • 4)Two groups of obstacle detector modules, to detect whether there are obstacles on the left or right side of smart car; Ultrasonic module is used to detect the distance between ultrasonic and obstacles, forming the smart car’s obstacle avoidance system;
  • 5)Bluetooth wireless module can be paired with Bluetooth device on mobile phone to remotely control smart car;
  • 6)Infrared receiver module is matched with an infrared remote control to control the smart car;
  • 7)Can access the external 7 ~ 12V voltage.


Component List

When get this smart car kit, at first glance, you will see the beautiful packaging box. And each component is safely packed inside the small bag in order. You will get such a bulk of components and screws to make your own smart car. So we have listed all the components as follows:

441图1.png

441图2.png

441图3.png

441图4.png

441图5.png


Software Introduction

1)Installing Arduino IDE

When program the UNO development board, you can download the Arduino integrated development environment from the link:


See more contents at:


Ks0436-9.png

The functions of each button on the Toolbar are listed below:
IDE.png

IDE 1.png Verify/Compile Check the code for errors
IDE 2.png Upload Upload the current Sketch to the Arduino
IDE 3.png New Create a new blank Sketch
IDE 4.png Open Show a list of Sketches
IDE 5.png Save Save the current Sketch
IDE 6.png Serial Monitor Display the serial data being sent from the Arduino


Or you can browse the KEYESTUDIO website at this link, https://www.keyestudio.com/ and then click on the WIKI Tutorial.
Ks0446图片6.png



2)Introduction for Mixly Blocks

Mixly is a free open-source graphical Arduino programming software, based on Google’s Blockly graphical programming framework, and developed by Mixly Team@ BNU.
It is a free open-source graphical programming tool for creative electronic development; a complete support ecosystem for creative e-education; a stage for maker educators to realize their dreams.
More info please check the link to download the Mixly blocks software.

Before starting the robot projects, please click the link to get the basic understanding of Mixly software.
Ks0446图片8.png



3)Import Robot Library

For the robot kit, we have developed keyestudio robot car library.
Don’t forget to import the keyestudio desktop car library to Mixly software before coding the robot projects.
Must import the robot car library first, or else you CANN'T check all the test code.


441图6.png

Unzip the desktop_car library package, you can see the desktop_car XML.document.
441图7.png

Then import this document into Mixly library. Import custom library successfully!
441图8.png

You are able to click “Manager” to manage all imported libraries.
Note: sometimes it may exists a conflict between libraries, so should keep only correct car library when using and delete other library.

441图9.png



Projects Guide


Project 1: Built-in LED

Keyestudio UNO R3

When it comes to using the UNO R3 as core of our robot, the UNO is the best board to get started with electronics and coding.
If this is your first experience tinkering with the platform, the UNO is the most robust board you can start playing with.
Well, let's at first have a look at this UNO R3 board.

Here is an explanation chart of what every element and interface of the board does:
Ks0001-pinout.png

KS0001 5-1.png ICSP (In-Circuit Serial Programming) Header

In most case, ICSP is the AVR,an Arduino micro-program header consisting of MOSI, MISO, SCK, RESET, VCC, and GND. It is often called the SPI (serial peripheral interface) and can be considered an "extension" of the output. In fact, slave the output devices under the SPI bus host.
When connecting to PC, program the firmware to ATMEGA328P-PU.

KS0001 5-2.png Power LED Indicator

Powering the Arduino, LED on means that your circuit board is correctly powered on. If LED is off, connection is wrong.

KS0001 5-3.png Digital I/O

Arduino UNO has 14 digital input/output pins (of which 6 can be used as PWM outputs). These pins can be configured as digital input pin to read the logic value (0 or 1). Or used as digital output pin to drive different modules like LED, relay, etc. The pin labeled “〜” can be used to generate PWM.

KS0001 5-4.png GND ( Ground pin headers)

Used for circuit ground

KS0001 5-5.png AREF

Reference voltage (0-5V) for analog inputs. Used with analogReference().

KS0001 5-6.png SDA

IIC communication pin

KS0001 5-7.png SCL

IIC communication pin

KS0001 5-8.png ICSP (In-Circuit Serial Programming) Header

In most case, ICSP is the AVR,an Arduino micro-program header consisting of MOSI, MISO, SCK, RESET, VCC, and GND. Connected to ATMEGA 16U2-MU. When connecting to PC, program the firmware to ATMEGA 16U2-MU.

KS0001 5-9.png RESET Button

You can reset your Arduino board, for example, start the program from the initial status. You can use the RESET button.

KS0001 5-10.png D13 LED

There is a built-in LED driven by digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.

KS0001 5-11.png USB Connection

Arduino board can be powered via USB connector. All you needed to do is connecting the USB port to PC using a USB cable.

KS0001 5-12.png ATMEGA 16U2-MU

USB to serial chip, can convert the USB signal into serial port signal.

KS0001 5-13.png TX LED

Onboard you can find the label: TX (transmit) When Arduino board communicates via serial port, send the message, TX led flashes.

KS0001 5-14.png RX LED

Onboard you can find the label: RX(receive ) When Arduino board communicates via serial port, receive the message, RX led flashes.

KS0001 5-15.png Crystal Oscillator

Helping Arduino deal with time problems. How does Arduino calculate time? by using a crystal oscillator.
The number printed on the top of the Arduino crystal is 16.000H9H. It tells us that the frequency is 16,000,000 Hertz or 16MHz.

KS0001 5-16.png Voltage Regulator

To control the voltage provided to the Arduino board, as well as to stabilize the DC voltage used by the processor and other components.
Convert an external input DC7-12V voltage into DC 5V, then switch DC 5V to the processor and other components.

KS0001 5-17.png DC Power Jack

Arduino board can be supplied with an external power DC7-12V from the DC power jack.

KS0001 5-18.png IOREF

Used to configure the operating voltage of microcontrollers. Use it less.

KS0001 5-19.png RESET Header

Connect an external button to reset the board. The function is the same as reset button (labeled 9)

KS0001 5-20.png Power Pin 3V3

A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.

KS0001 5-21.png Power Pin 5V

Provides 5V output voltage

KS0001 5-22.png Vin

You can supply an external power input DC7-12V through this pin to Arduino board.

KS0001 5-23.png Analog Pins

Arduino UNO board has 6 analog inputs, labeled A0 through A5.
These pins can read the signal from analog sensors (such as humidity sensor or temperature sensor), and convert it into the digital value that can read by microcontrollers) Can also used as digital pins, A0=D14, A1=D15, A2=D16, A3=D17, A4=D18, A5=D19.

KS0001 5-24.png Microcontroller

Each Arduino board has its own microcontroller. You can regard it as the brain of your board.
The main IC (integrated circuit) on the Arduino is slightly different from the panel pair. Microcontrollers are usually from ATMEL. Before you load a new program on the Arduino IDE, you must know what IC is on your board. This information can be checked at the top of IC.



Let’s make a simple test for the UNO built-in LED (D13).
We will work on blinking an LED. That’s right - it’s as simple as turning a light on and off!
Now enough talking - let’s get started with the LED project.

Blinking an LED
It’s pretty simple to turn a built-in led on and off. We only require UNO R3 control board and a USB cable to enter the wonderful programming world.
Connect your UNO R3 board to the computer’s USB port using a USB cable for communication.

0428图片15.png


Test Code:
Open Mixly blocks platform to get started with coding.
First, click IN/OUT, drag the “DigitalWrite PIN# (0)Stat(HIGH)” block.

0428图片16.png

This block is used to set the level HIGH or LOW of Digital pin.

  • Select HIGH is to set the HIGH level.
  • Select LOW is to set the LOW level.
  • The HIGH level is the state of high voltage, generally recorded as 1.
  • High voltage, high current, the LED lights.
  • The LOW level is the state of low voltage, generally recorded as 0.
  • Low voltage, low current, the LED Not lights.

To observe the LED blink obviously, we need to add a Delay block.
Check the test code below and upload it to your UNO R3 board.
0428图片17.png

What you should see:
Drag the test code to Mixly window; remember to select the proper board and COM port.
Then compile and upload the code to your control board. Upload success message will appear on the bottom bar.
The UNO built-in LED (label “L”) will turn on for 1 second, and then turn off for 1 second, alternately and circularly.

0428图片18.png

0428图片19.png



Project 2: LED Blink

keyestudio LED module


Overview:
LED blink is one of the most basic experiments in learning programming.
This project we use keyestudio white LED module. You will learn first how to blink an LED.

There are three lead-out pins on the module, respectively negative pin(marked -), positive pin(marked +) and signal pin(marked S).
Separately connect the white LED module to the pin G, 5V and D3 of keyestudio motor drive shield V2 using three F-F jumper wires. Then stack the motor drive shield V2 onto the UNO control board.


441图11.png

Done wiring, upload the test code to the board, so as to turn on an LED light.


Test Code:
Note: uploading the test code, DO NOT connect the Bluetooth module to motor drive shield. Otherwise, code upload fails.
441图12.png


Result:

441图13.png
Done uploading the code, turn the slide switch ON.
You will see the LED module turn on for one second, then off gone second.
441图14.png



  • Little Knowledge:

1.In the code, we’ve set the LED signal pin to D3 in the library; we can set the led signal pin without using library.
To make the same effect, you can use the block:
441图15.png or 441图16.png

2.What happens when you change the number in one or both of the delay(1000)
441图17.png
This delay period is in milliseconds, so if you want the LED to blink as low or fast, change the value, try 500 or 2000.



  • Extension Practice:

Try making the LED blink without using library. Set the LED signal to D11, and turn on for 0.5 second; off for 0.2 second, alternately and circularly.



Project 3: Obstacles Detection


Overview:
The robot car kit is packed with 2 infrared obstacle detector sensors.
The infrared obstacle detector sensor is actually a distance-adjustable obstacle avoidance sensor designed for a wheeled robot.
It has a pair of infrared transmitting and receiving tubes. The transmitter emits an infrared rays of a certain frequency. When the detection direction encounters an obstacle (reflecting surface), the infrared rays are reflected back, and receiving tube will receive it. At this time, the indicator lights up. After processed by the circuit, the signal output terminal will output Digital signal.
You can rotate the potentiometer knob on the sensor to adjust the detection distance.
The effective distance is 2-40cm and the working voltage is 3.3V-5V.


441图18.png

TECH SPECS:

  • Operating Voltage: DC 3.3-5V
  • Detection Distance: 2-40cm
  • Interface: 3PIN
  • Output Signal: Digital signal


In this project, we read the signal level of obstacle detector sensor to judge whether detect obstacles or not.
When detects an obstacle, sensor’s signal pin outputs LOW (display 0); otherwise, output HIGH (display 1).
Show the result on the serial monitor, and control the external LED module turn ON/OFF.


Wiring Diagram:
Connect two infrared obstacle detector modules and an LED module to keyestudio motor drive shield V2. Then stack the motor drive shield onto UNO control board.
441图19.png


Test Code:

441图20.png


Special note:
You can turn the tirmpot on the obstacle detector sensor to adjust the inductive sensitivity. Rotate the potentiometer near the infrared emitter to the end clockwise, then adjust the potentiometer near the infrared receiver to observe the Sled light, turn the Sled light off, and keep the critical point to be lit. The sensitivity is the best.


Result:
Done wiring, connect the UNO control board to computer’s USB port with USB cable to upload the code.
Code upload success, open the serial monitor, and set the baud rate to 9600. We can see the HIGH or LOW level of signal pin of left and right sensors. As shown below.
When any sensor detects obstacle (output 0), external LED module will turn on; otherwise, LED turns off.
441图21.png




  • Little Knowledge:

1.In the code,we use the library 441图22.png to read the HIGH/LOW of the left infrared avoiding sensor (A0); using the block 441图23.png also makes sense. The signal pin of the right infrared avoiding sensor is A2.


2.Ks0446图片30.png means the baud rate is set to 9600;
0428图片43.png Print the specified number, text or other value on serial monitor.
0428图片44.pngPrint the specified number, text or other value on newline of monitor.

3.0428图片45.pngmeans that if condition 1 is satisfied, it's going to be A, otherwise it's going to be B.
When using, you can find the if...do...statement block in the Mixly Control Block. Then click the gear icon on the block to drag out the else or else if block you need to use.
0428图片46.png

4.441图30.pngThis is a logical statement. It’s available as long as can satisfy any one of the two conditions.



  • Extension Practice:

1.Change the test code without using the library, making the same function.
2.Set the two control pins of infrared avoiding sensor to turn on or off the LED.



Project 4: Playing Melody

441图31.png


Overview:
The keyestudio power amplifier module integrates an adjustable potentiometer, a passive buzzer speaker, an audio amplifier 8002B chip and 3pin header interface.
When testing, we can input square waves of different frequency at the signal pin to make passive buzzer speaker produce a sound.
We can turn the potentiometer to adjust the sound amplification, that is, to adjust the sound volume.
In this project, we will code the buzzer in power amplifier module to produce a tone. And if string a bunch of tones together, you’ve got music!

For connection, we connect the power amplifier module to the pin G, 5V, D11 of motor drive shield V2; then stack the motor drive shield onto UNO control board.
Wiring Diagram:
441图32.png


Test Code:
Code 1: play a tone
441图33.png

Code 2: do re mi fa so la si do
441图34.png

Code 3: Ode to Joy
441图35.png


Result:
Done wiring, connect the UNO control board to computer’s USB port with USB cable to upload the code. Then turn the slide switch ON.
Upload code 1, buzzer will produce a tone of 440Hz for 0.2 second then off for 0.2 second, circularly.
Upload code 2, buzzer will play a tune “do re mi fa so la si do” circularly.
Upload code 3, buzzer will play a song Ode To Joy circularly.
441图36.png

Remember that you can turn the potentiometer to adjust the sound volume if can’t hear the tone.
441图37.png



  • Little Knowledge:

1.In the code 1, we use the library441图38.png, the signal pin of passive buzzer module is connected to D11, with a frequency of 440Hz tone. Note that you can click the Code on the Mixly window to check out the Arduino code.
441图39.png

2.In the code 1441图40.png means the buzzer will make no tone.
3.In the code 2441图41.png, we set the buzzer can play different tones of different frequencies.
4.In the code 3441图42.png, means the buzzer will play a specific song. You can choose the tune Ode to Joy, or Birthday.



  • Extension Practice:

1.For code 3, you can click to check out the corresponding language C; find out the tone of corresponding frequency and duration time, then refer to the code 2, try write into your own code.
441图43.png


  • Tips:

441图44.png set the frequency; 441图45.png set a period of time;

The corresponding frequency of the first M3 is 658Hz; and the duration time is 300*1=300ms. The rest is in the same manner.
441图46.png


Project 5: Obstacles Alarm


Overview:
The ultrasonic module will emit the ultrasonic waves after trigger signal. When the ultrasonic waves encounter the object and are reflected back, the module outputs an echo signal, so it can determine the distance of object from the time difference between trigger signal and echo signal.
The ultrasonic module is commonly used in robot car DIY process. It can detect whether an obstacle ahead and we can measure the distance between ultrasonic sensor and obstacles by calculation.
When DIY smart car, we can use the measured distance data to program the robot car avoiding or following obstacles.

In this project, we are going to measure the distance between ultrasonic module and obstacles ahead, triggering the power amplifier module to make a sound.
When the measured distance between ultrasonic and obstacles ahead is less than 10cm, the speaker will produce a tone of 440Hz; otherwise, not sound.
441图47.png


TECH SPECS:

  • Operating Voltage: DC 5V
  • Operating Current: 15mA
  • Operating Frequency: 40khz
  • Maximum Range: 2-3m
  • Minimum Range: 2m
  • Sensing Angle: 15 degrees
  • Trigger Input Signal: 10µS TTL pulse


Wiring Diagram:
Connect Ultrasonic module and power amplifier module to keyestudio motor drive shield V2.
Then stack the motor drive shield onto UNO control board.
441图48.png


Test Code:

441图49.png


Result:
Done wiring, connect the UNO control board to computer’s USB port with USB cable to upload the code.
Code upload success, open the serial monitor, and set the baud rate to 9600. You can see the distance between ultrasonic and obstacle ahead, with a unit of cm.
When the measured distance between ultrasonic and obstacles ahead is less than 10cm, the speaker will produce a tone of 440Hz; otherwise, not sound.
441图50.png




  • Little Knowledge:

1.In the code, we use the 441图51.png to measure the distance between ultrasonic sensor and obstacle ahead, with a unit of cm.
2.Ks0446图片30.png means the baud rate is set to 9600;
441图53.png: print the distance value on the newline of monitor.
But if you use the block 441图54.png, it will not print the value on the newline; just print on the monitor. The difference between them is whether need to make line wrap.
3.In the code also call the if...do... statement 0428图片45.png Refer to the detailed use in the project 3 please.



  • Extension Practice:

1.You can reset the distance measured by ultrasonic sensor. Change the different distance value to make the buzzer play a tone of different frequency.
441图56.png



Project 6: Motor Driving and Speed Control

Overview:

KS0435-3.png

There are many ways to drive the motor. Our robot uses the most commonly used L298P solution.
L298P is an excellent high-power motor driver IC produced by STMicroelectronics. It can directly drive DC motors, two-phase and four-phase stepping motors. The driving current up to 2A, and output terminal of motor adopts eight high-speed Schottky diodes as protection.
We have designed the motor driver shield V2 based on the L298P circuit.
The stackable design can make it be plugged directly into the Arduino, reducing the technical difficulty of using and driving the motor.
Direct stack the motor driver shield onto UNO R3 board, after the BAT is powered on, turn the Slide button ON, to supply the power for both keyestudio motor driver shield V2 and UNO R3 board.
For simple wiring, the motor driver shield comes with anti-reverse interfaces. When connecting the motor, power supply and sensor modules, you just need to plug in directly.

The Bluetooth interface on the motor driver shield is fully compatible with keyestudio HM-10 Bluetooth module. When connecting, just plug HM-10 Bluetooth module into the corresponding interface.
At the same time, the motor drive shield has brought out extra digital and analog ports in 2.54mm pin headers, so that you can continue to add other sensors for experiments extension.
The motor drive shield can access to 4 DC motors, defaulted by jumper connection. The motor connector A and A1, connector B and B1 are separately in parallel.
The 8 jumpers can be applied to control the turning direction of 4 motors.
For instance, if change the 2 jumpers near the motor A connector from horizontal connection to vertical connection, the turning direction of motor A is opposite to the original rotation direction.

thumb


Specifications:

  • 1)Logic part input voltage: DC5V
  • 2)Driving part input voltage (limit): DC 6-18V
  • 3)Driving part input voltage (recommended): DC 7-12V
  • 4)Logic part working current: <36mA
  • 5)Driving part working current: <2A
  • 6)Maximum power dissipation: 25W (T=75℃)
  • 7)Working temperature: -25℃~+130℃


PINOUT Instructions:

thumb


Wiring Diagram:
Connect two motors to keyestudio motor drive shield V2; stack the motor drive shield onto UNO control board.
441图57.png


Driving Motor
According to the wiring diagram, default the jumper connection method.
Follow the table below to drive the 2 motors rotate by Digital, PWM pins, so as to control the robot car run.
The PWM value is in the range of 0-255. The greater the value set, the faster the motors rotate.

441图58.png


Test Code:

441图59.png


Result:
Done wiring, connect the UNO control board to computer’s USB port with USB cable to upload the code.
441图60.png

Upload success, turn the Slide switch ON. The 2 motors act like the smart car to turn forward for 2 seconds, backward for 2 seconds, and then turn left for 2 seconds, turn right for 2 seconds, stop for 2 seconds, alternately and circularly.
441图61.png



  • Little Knowledge:

1.The code logic is completely based on the motor driving reference table. Check it out.
2.The PWM value is in the range of 0-255. The greater the value set, the faster the motors rotate. Base on that, you can set the speed as you like.


  • Extension Practice:

1.Based on the logic table, try to reset a new moving track for your smart car.



Project 7: Library Driving Motor

Overview:
There are many ways to drive the motor. We have learned how to control the 2 motors in the previous section, so as to drive the smart car run. It is troublesome to control the smart car via control port. For this, we specially create the library to drive the robot car more simple and easier. When setting, the PWM value is in the range of 0-255. The greater the value set, the faster the motors rotate.


Wiring Diagram:
441图57.png


Test Code:
441图62.png


Result:
Done wiring, connect the UNO control board to computer’s USB port with USB cable to upload the code.
Upload success, turn the Slide switch ON. The 2 motors act like smart car to turn forward for 2 seconds, backward for 2 seconds, and then turn left for 2 seconds, turn right for 2 seconds, stop for 2 seconds, circularly.
441图63.png



  • Little Knowledge:

1.The code using library to set the car’s motion state, easy and simple, shortening the code length.
2.The control logic is the same as project 6-motor driving. We can click to check out the corresponding language C of motor mixly code.
441图64.png


  • Extension Practice:

1.Based on the logic table, try to reset a new moving track for your smart car.




Project 8: Line Tracking Sensor


Overview:
The tracking sensor is actually an infrared sensor. The component used here is the TCRT5000 infrared tube. Its working principle is to use the different reflectivity of infrared light to the color, then convert the strength of the reflected signal into a current signal.
During the process of detection, black is active at HIGH level, but white is active at LOW. The detection height is 0-3 cm.
For keyestudio 3-channel line tracking module, we have integrated 3 sets of TCRT5000 infrared tube on a single board. It is more convenient for wiring and control.
By rotating the adjustable potentiometer on the sensor, it can adjust the detection sensitivity of the sensor.

Special note: before testing, turn the potentiometer on the sensor to adjust the detection sensitivity.
When adjust the LED front the trimpot at the threshold between ON and OFF, the sensitivity is the best.


TECH SPECS:

  • Operating Voltage: 3.3-5V (DC)
  • Interface: 5PIN
  • Output Signal: Digital signal
  • Detection Height: 0-3 cm


441图66.png


Wiring Diagram:
Next let’s do a simple test for this tracking module. The connection diagram is shown as below.
441图67.png


Test Code:

441图68.png


Result:
441图69.png
Done wiring, connect the UNO control board to computer’s USB port with USB cable to upload the code.
Upload success, turn the Slide switch ON.
When the left TCRT5000 infrared tube detects a white line, LED module lights; detecting a black line, LED turns off.
In a similar way, we use other 2-way TCRT5000 infrared tubes to detect the black-white line.
441图70.png



  • Little Knowledge:

1.In the code, we use the library 441图71.png to read the HIGH/LOW of the left sensor (D6); using the block 441图72.png also makes sense.
The signal pin of the middle sensor is D7; the signal pin of the right sensor is D8.
441图73.png
2.0428图片45.pngmeans that if condition 1 is satisfied, it's going to be A, otherwise it's going to be B.
When using, you can find the if...do...statement block in the Mixly Control Block. Then click the gear icon on the block to drag out the else or else if block you need to use.
0428图片46.png



  • Extension Practice:

1.Change the test code without using the library, making the same result.
2.Set the 3 control pins of line tracking sensor to turn on or off 3 LEDS.



Project 9: Infrared Receiver


  • IR Remote Control:
remote control

There is no doubt that infrared remote control is commonly seen in our daily life. It's hard to imagine our world without it.
An infrared remote control can be used to control a wide range of home appliances such as television, audio, video recorders and satellite signal receivers.
Well, in the following let’s get a better understanding of the infrared remote control.

Infrared remote control is composed of infrared transmitting and infrared receiving systems. That is, consist of an infrared remote control, an infrared receiver module and a microcontroller that can decode. You can refer to the figure below.

Ks0436-201.png

The 38K infrared carrier signal transmitted by an infrared remote controller is encoded by an encoding chip inside the remote controller. It is composed of a pilot code, user code, data code, and data inversion code.
The time interval between pulses is used to distinguish whether it is a signal 0 or 1. (when the ratio of high level to low level is about 1:1, considered as signal 0.) And the encoding is just well composed of signal 0 and 1.

The user code of the same button on remote controller is unchanged. Using difference data distinguish the key pressed on the remote control.
When press down a button on the remote control, it will send out an infrared carrier signal. And when infrared receiver receives that signal, its program will decode the carrier signal, and through different data codes, thus can judge which key is pressed.
The microcontroller is decoded by an received signal 0 or 1 to determine which key is pressed by the remote control.


  • IR Receiver Module:

As for an infrared receiver module, it is mainly composed of an infrared receiving head. This device integrates with reception, amplification and demodulation. Its internal IC has been demodulated, outputting Digital signal. Suitable for IR remote control and infrared data transmission.
The infrared receiver module has only three pins (Signal, VCC, GND), very convenient to communicate with Arduino and other microcontrollers.

IR Receiver Module


Parameters of IR Receiver:

  • 1)Operating Voltage: 3.3-5V(DC)
  • 2)Interface: 3PIN
  • 3)Output Signal: Digital signal
  • 4)Receiving Angle: 90 degrees
  • 5)Frequency: 38khz
  • 6)Receiving Distance: 18m


Hookup Guide:
Let’s connect the infrared receiver to motor drive shield to make a simple test.
441图75.png


Test Code:
441图76.png


Test Result:
Code upload success, open the serial monitor, and set the baud rate to 9600.
Press your remote control, aimed at the infrared receiver, to send the signal, and you will see the encoding of each button on the remote control.
Note if press the control button too long, easily appear unreadable code. Shown as below figure.
441图77.png


Below we have listed out each button value of keyestudio remote control. So you can keep it for reference.
thumb



Little Knowledge:
1.In the code, we direct use the library441图78.png; the signal pin of IR receiver module is A1; the IR receiver receives an infrared signal and outputs 16-bit encoding, printing out on serial monitor (baud rate 9600). 2.We can test out the 16-bit encoding of each button on the infrared remote control by source code. Or you can see the button encoding chart shown above.


Extension Practice:
1.Turning on or off several LED modules by infrared remote control.
2.Driving the 2 motors’ turning direction and speed by infrared remote control.
(refer to project 6- motor driving)
Combine infrared receiver and motors driving knowledge to build an infrared remote control car.




Assembly Steps for Desktop Car

441图79.png


Follow the assembly steps below to build your own robot.

1) Bottom motor parts

You should mount two motors on the Acrylic bottom board.
Prepare the components as follows:

  • M2 Nut *4
  • White N20 motor holder *2
  • 12FN20 motor connector *2
  • M2*10MM round-head screw *4
  • Acrylic bottom board *1


441图80.png

First place four M2 Nuts inside the holes of white N20 motor holders.
441图81.png

Note: the Acrylic plate is marked with A, B for the two motors. Mount the motor A to label A on the Acrylic plate; motor B to Acrylic position B.

Then mount the white N20 holders onto the motors.
441图82.png

Fix these two 12FN20 motor connectors on the Acrylic bottom plate with four M2*10MM round-head screws.
441图83.png

441图84.png


2) Battery case

You can choose the 18650 2-cell battery case or 4-cell AA battery case.Mount the battery case on the acrylic bottom board.
Here we install the 4-cell AA battery case for the smart car. You should first get some parts below:

  • 4-cell Battery case*1
  • M3*8MM flat-head screws *2
  • M3 Nut *2

Fix the battery case on the top of Acrylic board using two M3*8MM flat-head screws and two M3 Nuts.
441图85.png

441图86.png


3) Tracking sensor and wheels

Assemble the line tracking sensor and connect the wire:

  • JST-PH2.0MM-2P 24AWG red-black wire 160mm *2
  • JST-PH2.0MM-5P blue-green-yellow-red-black connector wire 15CM *1
  • M3*5+6MM single-pass copper pillars *2
  • M3*6MM round-head screws *2
  • M3 Nut *2
  • Wheel *2
  • Line tracking sensor *1


441图87.png

Connect 2 pieces of JST-PH2.0MM-2P red-black wire 160mm to the 12FN20 motor connectors. Connect two wheels to the motor spin.
441图88.png

Insert two M3*5+6MM single-pass copper pillars into the holes on the line tracking sensor, and tighten two M3 Nuts on the copper pillars. Shown below.
441图89.png441图90.png

After that, mount the line tracking sensor on the Acrylic board with two M3*6MM round-head screws.
441图91.png

Connect a JST-PH2.0MM-5P 24AWG blue-green-yellow-red-black connector wire 15CM to the connector of tracking sensor. Shown below.
441图92.png


Completed the above assembly, let's install the caster for this small car.

  • W420 ball caster wheel *1
  • M3*6MM round-head screws *6
  • M3 Nut *2
  • M3*8+6MM single-pass copper pillar *2
  • M3*40MM dual-pass copper pillar *4


441图93.png

441图94.png441图95.png

Screw the W420 ball caster wheel on the Acrylic bottom board with two M3*6MM round-head screws, two M3 Nuts, two M3*8+6MM single-pass copper pillars.
441图96.png

Screw four M3*40MM dual-pass copper pillars on the 4 corner holes on acrylic bottom board with four M3*6MM round-head screws.
441图97.png

441图98.png441图99.png


4) Ultrasonic module

Now should install the particular eyes for this smart car, i.e. Ultrasonic module.

  • Ultrasonic module *1
  • M3*10MM round-head screw *4
  • M3 Nut *4
  • Ultrasonic acrylic board *1
  • JST-PH2.0MM-4P connector wire 8CM *1


441图100.png
Look at the figure below, fix the ultrasonic module on the acrylic board with four M3*10MM round-head screws and four M3 Nuts.
Then connect the JST-PH2.0MM-4P connector wire to ultrasonic module.
441图101.png



5) Acrylic top board

Fix other sensors on the Acrylic top board. Prepare parts as follows:

  • Acrylic top board *1
  • Obstacle detector sensor *2
  • IR receiver sensor *1
  • Keyestudio power amplifier module *1
  • M3*10MM round-head screw *4
  • M3 Nut *8
  • M3*8+6MM single-pass copper pillar*4
  • JST-PH2.0MM-3P yellow-red-black wire 8CM *3
  • 3pin F-F jumper wire *1


441图102.png

Tighten four M3*8+6MM single-pass copper pillars on the acrylic top board with four M3 Nuts.
441图103.png

Separately mount two obstacle detector sensors and an IR receiver sensor on Acrylic top plate with three M3*10MM screws and three M3 Nuts.
441图104.png

Mount keyestudio power amplifier module on Acrylic top plate with a M3*10MM screw and a M3 Nut.
441图105.png

441图106.png

Connect the wire to the keyestudio power amplifier module, obstacle detector sensors and an IR receiver sensor.
441图107.png



6) Complete Car

Till now, the smart car is almost installed well.
Assemble all the finished parts and install the control board as follows:

  • UNO R3 main board *1
  • Motor drive shield *1
  • Bluetooth module*1
  • Jumpers cap *8
  • M3*6MM round-head screw *8


441图108.png

441图109.png

Firstly, insert the ultrasonic module into the two holes of Acrylic bottom board.
Then, screw the Acrylic top board to the copper pillars mounted on Acrylic bottom plate with four M3*6MM round-head screws.
441图110.png

After that, mount the UNO R3 main board onto the Acrylic top board with four M3*6MM round-head screws.
And stack the motor drive shield onto UNO R3 board.
441图111.png

441图112.png

Finally insert the 8 jumpers and HM-10 Bluetooth module into the motor drive shield.
(8 jumpers direction are by default; changing the jumper direction will change the motor turning direction)
441图113.png

441图114.png


Up to now, you have finished the hardware installation of the smart car. Congrats!
For wiring, you can connect all the wires according to the corresponding silk-screen on the board.
Connection diagram:
441图115.png

Keyestudio Desktop Mini Bluetooth Smart Car V3.0


The Desktop car is now completing installation.
Follow the detailed project instructions to build your own robot with various functions.



Project 10: Following Robot


Circuit Design:
In the above sections we already introduced the motor drive shield, sensor, module, motors and other elements.
According to the project 3/5/7 -- obstacle detection, obstacle alarm, and library driving motor,
we’re now ready to give the robot capability - Object Following!

In the project, we make the robot measure whether exist obstacles at both sides with obstacle detector sensors. Measure the distance between obstacle and robot, and then use the measured data to rotate the two motors, so as to control the robot car run.


Below is a specific logic table of following robot for reference:
441图117.png


Build Following Robot:
Based on the designed circuit, we are going to build a following robot car.
Check the circuit diagram and test code below.

441图118.png


Test Code:
Can’t connect the Bluetooth module when upload the code, otherwise, code upload fails.
You should upload the code success, then plug in the Bluetooth module.

441图119.png


Result:
Stack the motor drive shield onto UNO board. Connect the UNO control board to computer’s USB port with USB cable to upload the code.
Upload success and turn the slide switch to ON position. The robot will follow the front object to move.
441图116.png


Project 11: Obstacle Avoiding Robot


Circuit Design:
We’re now ready to give the robot another capability - Obstacle Avoiding!
It is pretty simple. Just keep the same components and connection method as following robot, but need to change the code.


Below is a specific logic table of following robot for reference:
441图120.png


Build Obstacle Avoiding Robot:
Based on the designed circuit, we are going to build an obstacle avoiding robot car.
Check the circuit diagram and test code below.

441图121.png


Test Code:
Can’t connect the Bluetooth module when upload the code, otherwise, code upload fails.
You should upload the code success, then plug in the Bluetooth module.

441图122.png


Result:
Upload success and turn the slide switch to ON position.
The robot can automatically avoid the front obstacle to run.
441图123.png



Project 12: Line Tracking Robot


Circuit Design:
In the above sections we already introduced the motor drive shield, sensor, module, motors and other elements.
According to the project 7/8 -- library driving motor, line tracking sensor,
we’re now ready to give the robot capability - Line Tracking!
In the project, we make the robot detect black line at the car bottom with line tracking sensor. Then control the 2 motors rotate by measured result, so as to drive the robot track black line.


Below is a specific logic table of line tracking robot for reference:
441图120.png


Build Obstacle Avoiding Robot:
Based on the designed circuit, we are going to build an obstacle avoiding robot car.
Check the circuit diagram and test code below.

441图121.png


Test Code:
Can’t connect the Bluetooth module when upload the code, otherwise, code upload fails.
You should upload the code success, then plug in the Bluetooth module.

441图122.png


Result:
Upload success and turn the slide switch to ON position.
The robot can automatically avoid the front obstacle to run.
441图123.png


Resources

  • Get all the resources here:

https://1drv.ms/u/s!ArhgRvK6-RyJcxRRe3SxqYE_X3I?e=fJHrQl

  • Video:

http://video.keyestudio.com/ks0441/



About keyestudio

Located in Shenzhen, the Silicon Valley of China, KEYES DIY ROBOT co.,LTD is a thriving technology company dedicated to open-source hardware research and development, production and marketing.

Keyestudio is a best-selling brand owned by KEYES Corporation, our product lines range from Arduino boards, shields, sensor modules, Raspberry Pi, micro:bit extension boards and smart car to complete starter kits designed for customers of any level to learn Arduino knowledge.

All of our products comply with international quality standards and are greatly appreciated in a variety of different markets throughout the world.
Welcome check more contents from our official website:
http://www.keyestudio.com

Logo图片1.png


For more details of our products, you can check it from the links below.


Customer Service

As a continuous and fast growing technology company, we keep striving our best to offer you excellent products and quality service as to meet your expectation.
We look forward to hearing from you and any of your critical comment or suggestion would be much valuable to us.
You can reach out to us by simply drop a line at: Fennie@keyestudio.com
Thank you in advance.



Buy From