Ks0192 keyestudio 4WD Bluetooth Multi-functional Car: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
 
(57 intermediate revisions by the same user not shown)
Line 1: Line 1:
==keyestudio 4WD Bluetooth Multi-functional Car==
<br>[[File:1921.png|500px|frameless|thumb]]<br>


==Introduction==
==Introduction==
[http://www.keyestudio.com/keyestudio-4wd-bluetooth-multi-functional-car.html  keyestudio 4WD Bluetooth Multi-functional Car] is a learning application development system based on microcontroller and with ATmega-328 as core. It has functions of line tracking, obstacle avoidance, IR remote control, Bluetooth remote control and distance detection. This kit contains plenty of interesting programs and can extend an external circuit module to increase more functions of this car. The kit aims to disengage users from boring theories and obtain capacity of system development when they are learning [https://www.arduino.cc/en/Guide/Introduction  Arduino ].
[http://www.keyestudio.com/keyestudio-4wd-bluetooth-multi-functional-car.html  keyestudio 4WD Bluetooth Multi-functional Car] is a learning application development system based on microcontroller and with ATmega-328 as core. It has functions of line tracking, obstacle avoidance, IR remote control, Bluetooth remote control and distance detection. This kit contains plenty of interesting programs and can extend an external circuit module to increase more functions of this car. The kit aims to disengage users from boring theories and obtain capacity of system development when they are learning [https://www.arduino.cc/en/Guide/Introduction  Arduino ].


<br>
==Parameters==
==Parameters==
 
* 1.Motor: Voltage: 6-9V    Reduction Ratio: 1:48<br>
1.Motor: Voltage: 6-9V    Reduction Ratio: 1:48<br>
* 2.Choosing [http://www.keyestudio.com/l298n-motor-driver-board-module-l298-for-arduino-stepper-motor-smart-car-robot.htm  L298N driver module l] as control motor, separated from microcontrollor<br>
2.Choosing [http://www.keyestudio.com/l298n-motor-driver-board-module-l298-for-arduino-stepper-motor-smart-car-robot.htm  L298N driver module l] as control motor, separated from microcontrollor<br>
* 3.Three line tracking modules, having higher precision when detecting white and black lines,able to realize anti-falling<br>
3.Three line tracking modules, having higher precision when detecting white and black lines,able to realize anti-falling<br>
* 4.[http://www.keyestudio.com/keyestudio-digital-ir-receiver-module-for-arduino.html  IR remote control module ] making up a remote control system of the car<br>
4.[http://www.keyestudio.com/keyestudio-digital-ir-receiver-module-for-arduino.html  IR remote control module ] making up a remote control system of the car<br>
* 5.Using ultrasonic module to realize obstacle avoidance<br>
5.Using ultrasonic module to realize obstacle avoidance<br>
* 6.Pairing mobile phone Bluetooth with Bluetooth remote control module to control the car<br>
6.Pairing mobile phone Bluetooth with Bluetooth remote control module to control the car<br>
* 7.Able to connect with external voltage at 7~12V,and equipped with various sensors to complete different functions as much as possible <br>
7.Able to connect with external voltage at 7~12V,and equipped with various sensors to complete different functions as much as possible <br>


<br>
==Component List==
==Component List==
{| width="80%" cellspacing="0" border="1"
{| width="80%" cellspacing="0" border="1"
|-
|-
Line 43: Line 39:
| align="center" |keyestudio L298N Motor Shield   
| align="center" |keyestudio L298N Motor Shield   
| align="center" | 1  
| align="center" | 1  
| align="center" | <br>[[File:1924.png|500px|frameless|thumb]]<br>
| align="center" | <br>[[File:L298N.png|100px|frameless|thumb]]<br>
|-
|-
   
   
Line 49: Line 45:
| align="center" | keyestudio Bluetooh HC-06  
| align="center" | keyestudio Bluetooh HC-06  
| align="center" | 1
| align="center" | 1
| align="center" | <br>[[File:1925.png|500px|frameless|thumb]]<br>
| align="center" | <br>[[File:KS0192-6.png|500px|frameless|thumb]]<br>
|-
|-


Line 73: Line 69:
| align="center" | keyestudio Digital IR Receiver Module   
| align="center" | keyestudio Digital IR Receiver Module   
| align="center" | 1  
| align="center" | 1  
| align="center" | <br>[[File:1929.png|200px|frameless|thumb]]<br>
| align="center" | <br>[[File:KS0192-7.png|200px|frameless|thumb]]<br>
|-
|-
   
   
Line 91: Line 87:
| align="center" | Servo Motor   
| align="center" | Servo Motor   
| align="center" | 1
| align="center" | 1
| align="center" | <br>[[File:19212.png|200px|frameless|thumb]]<br>
| align="center" | <br>[[File:KS0192-2.png|200px|frameless|thumb]]<br>
|-
|-
   
   
Line 103: Line 99:
| align="center" | Remote Control of Chip  
| align="center" | Remote Control of Chip  
| align="center" | 1
| align="center" | 1
| align="center" | <br>[[File:19214.png|500px|frameless|thumb]]<br>
| align="center" | <br>[[File:KS0192-1.png|500px|frameless|thumb]]<br>
|-
|-
   
   
Line 113: Line 109:
   
   
| align="center" | 15
| align="center" | 15
| align="center" | 18650 Battery Case
| align="center" | 18650 Battery Holder
| align="center" | 1
| align="center" | 1
| align="center" | [[File:19216.png|500px|frameless|thumb]]
| align="center" | [[File:19216.png|500px|frameless|thumb]]
Line 137: Line 133:
   
   
| align="center" | 19
| align="center" | 19
| align="center" | Copper Pillar 35MM
| align="center" | Copper Pillar 40MM
| align="center" | 6
| align="center" | 6
| align="center" | <br>[[File:19220.png|500px|frameless|thumb]]<br>
| align="center" | <br>[[File:19220.png|500px|frameless|thumb]]<br>
Line 143: Line 139:
   
   
| align="center" | 20
| align="center" | 20
| align="center" | Copper Pillar 20MM
| align="center" | Copper Pillar 10MM
| align="center" | 3
| align="center" | 16
| align="center" | <br>[[File:19221.png|500px|frameless|thumb]]<br>
| align="center" | <br>[[File:Ks0192-copper.png|500px|frameless|thumb]]<br>
|-
|-


| align="center" | 21
| align="center" | 21
| align="center" | Copper Pillar 6MM
| align="center" | 6
| align="center" | [[File:19222.png|500px|frameless|thumb]][[File:19222.png|500px|frameless|thumb]][[File:19222.png|500px|frameless|thumb]][[File:19222.png|500px|frameless|thumb]][[File:19222.png|500px|frameless|thumb]][[File:19222.png|500px|frameless|thumb]]
|-
| align="center" | 22
| align="center" | USB Cable  
| align="center" | USB Cable  
| align="center" | 1
| align="center" | 1
Line 160: Line 150:
|-
|-


| align="center" | 23
| align="center" | 22
| align="center" | Dupont Line  
| align="center" | Dupont Line  
| align="center" | 30
| align="center" | 30
Line 166: Line 156:
|-
|-


| align="center" | 24
| align="center" | 23
| align="center" | M3*6MM  Round Head Screw
| align="center" | M3*6MM  Round Head Screw
| align="center" | 60
| align="center" | 60
Line 172: Line 162:
|-
|-


| align="center" | 25
| align="center" | 24
| align="center" | M3*6MM Flat Head Screw  
| align="center" | M3*8MM Flat Head Screw  
| align="center" | 2
| align="center" | 2
| align="center" | [[File:19226.png|500px|frameless|thumb]][[File:19226.png|500px|frameless|thumb]]
| align="center" | [[File:19226.png|500px|frameless|thumb]][[File:19226.png|500px|frameless|thumb]]
|-
|-


| align="center" | 26
| align="center" | 25
| align="center" | M3*30MM  Round Head Screw  
| align="center" | M3*30MM  Round Head Screw  
| align="center" | 8
| align="center" | 8
Line 184: Line 174:
|-
|-


| align="center" | 27
| align="center" | 26
| align="center" | 3MM Nut  
| align="center" | 3MM Nut  
| align="center" | 16
| align="center" | 16
Line 190: Line 180:
|-
|-


| align="center" | 28
| align="center" | 27
| align="center" | Connector Wire (150mm, Black)  
| align="center" | Connector Wire (150mm, Black)  
| align="center" | 6
| align="center" | 6
Line 196: Line 186:
|-
|-


| align="center" | 29
| align="center" | 28
| align="center" | Connector Wire (150mm, Red)  
| align="center" | Connector Wire (150mm, Red)  
| align="center" | 6
| align="center" | 6
Line 202: Line 192:
|-
|-


| align="center" | 30
| align="center" | 29
| align="center" | Winding Wire (12CM)  
| align="center" | Winding Wire (12CM)  
| align="center" | 1
| align="center" | 1
Line 208: Line 198:
|-
|-
|}
|}
<br>


==Project List==
==Project List==
Project 1:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_1:_Line_Tracking_Sensor  Line Tracking Sensor]<br>
Project 1:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_1:_Line_Tracking_Sensor  Line Tracking Sensor]<br>
Project 2:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_2:_Ultrasonic_Sensor  Ultrasonic Sensor ] <br>
Project 2:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_2:_Ultrasonic_Sensor  Ultrasonic Sensor ] <br>
Project 3:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_3:_Digital_IR_Receiver_Module  Digital IR Receiver Module ] <br> 
Project 3:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_3:_Digital_IR_Receiver_Module  Digital IR Receiver Module ]<br> 
Project 4:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_4:_Servo_Motor  Servo Motor ] <br>
Project 4:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_4:_Servo_Motor  Servo Motor ] <br>
Project 5:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_5:_Bluetooth_Module  Bluetooth Module ] <br>
Project 5:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_5:_Bluetooth_Module  Bluetooth Module ] <br>
Line 224: Line 215:
Project 12:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_12:_Bluetooth_Remote_Control_of_Smart_Car  Bluetooth Remote Control of Smart Car ]<br>
Project 12:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_12:_Bluetooth_Remote_Control_of_Smart_Car  Bluetooth Remote Control of Smart Car ]<br>
Project 13:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_13:_5_in_1_Muilti-functional_Car_.28Line_Tracking.2C_Obstacle_Avoidance.2C_Bluetooth_and_IR_Remote_Control.2C_Distance_Detecting.29  5 in 1 Muilti-functional Car ] <br>
Project 13:[http://wiki.keyestudio.com/index.php/Ks0192_keyestudio_4WD_Bluetooth_Multi-functional_Car#Project_13:_5_in_1_Muilti-functional_Car_.28Line_Tracking.2C_Obstacle_Avoidance.2C_Bluetooth_and_IR_Remote_Control.2C_Distance_Detecting.29  5 in 1 Muilti-functional Car ] <br>
<br>


==Address of Assembly Video==
==Address of Assembly Video==
http://video.keyestudio.com/ks0192/


[http://www.keyestudio.com/wp/2016/09/ks0192 http://www.keyestudio.com/wp/2016/09/ks0192]
<br>


==Address of Demonstration Video==
==Address of Demonstration Video==
Line 233: Line 227:
[http://www.keyestudio.com/wp/2016/09/ks0192-keyestudio-4wd-bluetooth-multi-functional-car-demonstration-video/ http://www.keyestudio.com/wp/2016/09/ks0192-keyestudio-4wd-bluetooth-multi-functional-car-demonstration-video/]
[http://www.keyestudio.com/wp/2016/09/ks0192-keyestudio-4wd-bluetooth-multi-functional-car-demonstration-video/ http://www.keyestudio.com/wp/2016/09/ks0192-keyestudio-4wd-bluetooth-multi-functional-car-demonstration-video/]


<br>


==Project Details==
==Project Details==
Line 254: Line 249:
'''Connection Diagram:'''
'''Connection Diagram:'''


<br>[[File:19233.png|500px|frameless|thumb]]<br>  
<br>[[File:19233.png|800px|frameless|thumb]]<br>  




Line 276: Line 271:
</pre>
</pre>


<br>
'''Result:'''
'''Result:'''


Line 281: Line 277:


'''Figure 1:'''
'''Figure 1:'''
<br>[[File:90.png|500px|frameless|thumb]]<br>
<br>[[File:90.png|700px|frameless|thumb]]<br>


'''Figure 2:'''
'''Figure 2:'''
<br>[[File:91.png|500px|frameless|thumb]]<br>
<br>[[File:91.png|700px|frameless|thumb]]<br>
 


<br>
===Project 2: Ultrasonic Sensor===
===Project 2: Ultrasonic Sensor===


Line 308: Line 306:
'''Connection Diagram:'''  
'''Connection Diagram:'''  


<br>[[File:Ks0192-pro2超声波.png|500px|frameless|thumb]]<br>
<br>[[File:Ks0192-pro2超声波.png|800px|frameless|thumb]]<br>


'''Sample Code:'''
'''Sample Code:'''
Line 367: Line 365:
'''Result:''' <br>
'''Result:''' <br>
After connection and uploading, when ultrasonic sensor senses obstacle within sensing area, it is measuring the distance between itself and obstacle and the value of distance is displayed on serial monitor as shown in below figure.
After connection and uploading, when ultrasonic sensor senses obstacle within sensing area, it is measuring the distance between itself and obstacle and the value of distance is displayed on serial monitor as shown in below figure.
<br>[[File:93.png|500px|frameless|thumb]]<br>
<br>[[File:93.png|700px|frameless|thumb]]<br>


<br>
===Project 3: Digital IR Receiver Module===
===Project 3: Digital IR Receiver Module===


<br>[[File:19236.png|500px|frameless|thumb]]<br>
<br>[[File:KS0192-4.png|600px|frameless|thumb]]<br>


'''Introduction:''' <br>
'''Introduction:''' <br>
Line 387: Line 386:
'''Connection Diagram:''' 
'''Connection Diagram:''' 


<br>[[File:19237.png|500px|frameless|thumb]]<br>
<br>[[File:19237.png|800px|frameless|thumb]]<br>




Line 412: Line 411:


[https://github.com/shirriff/Arduino-IRremote https://github.com/shirriff/Arduino-IRremote]
[https://github.com/shirriff/Arduino-IRremote https://github.com/shirriff/Arduino-IRremote]


'''Result:'''
'''Result:'''
In this project, we need to use a IR remote control which has 17 functional key and its launching distance is 8 meters at most, proper to control various devices indoors. This project is actually to decode remote control signal. After connection and uploading codes, aim at IR receiving module and press the key, finally you can see the corresponding codes. If you press the key too long, it will show messy codes easily as shown in below figure.
In this project, we need to use a IR remote control which has 17 functional key and its launching distance is 8 meters at most, proper to control various devices indoors. This project is actually to decode remote control signal. After connection and uploading codes, aim at IR receiving module and press the key, finally you can see the corresponding codes. If you press the key too long, it will show messy codes easily as shown in below figure.
<br>[[File:94.png|500px|frameless|thumb]]<br>
<br>[[File:94.png|700px|frameless|thumb]]<br>
<br>[[File:95.png|500px|frameless|thumb]]<br>
<br>[[File:95.png|700px|frameless|thumb]]<br>


<br>
===Project 4: Servo Motor===
===Project 4: Servo Motor===


<br>[[File:96.png|500px|frameless|thumb]]<br>
<br>[[File:KS0192-3.png|600px|frameless|thumb]]<br>


'''Introduction:'''
'''Introduction:'''
Line 430: Line 428:
Servomotor comes with many specifications. But all of them have three connection wires, distinguished by brown, red, orange color(different brand may have different color). Brown one is for GND, red one for power positive, orange one for signal Line.
Servomotor comes with many specifications. But all of them have three connection wires, distinguished by brown, red, orange color(different brand may have different color). Brown one is for GND, red one for power positive, orange one for signal Line.


<br>[[File:7492.png|500px|frameless|thumb]]<br>
<br>[[File:7492.png|700px|frameless|thumb]]<br>


The rotating angle of the servo motor is controlled by regulating the duty cycle of the PWM(Pulse-Width Modulation) signal. The standard cycle of the PWM signal is 20ms(50Hz). Theoretically, the width is distributed between 1ms-2ms, but in fact, it's between 0.5ms-2.5ms. The width corresponds the rotate angle from 0° to 180°. But note that for different brand motor, the same signal may have different rotating angle. 
The rotating angle of the servo motor is controlled by regulating the duty cycle of the PWM(Pulse-Width Modulation) signal. The standard cycle of the PWM signal is 20ms(50Hz). Theoretically, the width is distributed between 1ms-2ms, but in fact, it's between 0.5ms-2.5ms. The width corresponds the rotate angle from 0° to 180°. But note that for different brand motor, the same signal may have different rotating angle. 


<br>[[File:7493.png|500px|frameless|thumb]]<br>
<br>[[File:7493.png|700px|frameless|thumb]]<br>


Mastering some basic knowledge, let's learn how to control a servomotor. In this experiment, you only need a servomotor and several jumper wires. 
Mastering some basic knowledge, let's learn how to control a servomotor. In this experiment, you only need a servomotor and several jumper wires. 
Line 441: Line 439:
'''Connection & Sample Program:'''<br>
'''Connection & Sample Program:'''<br>
There are two ways to control a servomotor with Arduino. One is to use a common digital sensor port of Arduino to produce square wave with different duty cycle to simulate PWM signal and then use that signal to control the positioning of the motor. Another way is to directly use the Servo function of the Arduino to control the motor. In this way, the program will be more easier but it can only control two-contact motor because of the servo function, only digital pin 9 and 10 can be used. The Arduino drive capacity is limited. So if you need to control more than one motor, you will need external power.
There are two ways to control a servomotor with Arduino. One is to use a common digital sensor port of Arduino to produce square wave with different duty cycle to simulate PWM signal and then use that signal to control the positioning of the motor. Another way is to directly use the Servo function of the Arduino to control the motor. In this way, the program will be more easier but it can only control two-contact motor because of the servo function, only digital pin 9 and 10 can be used. The Arduino drive capacity is limited. So if you need to control more than one motor, you will need external power.


'''Connection Diagram:'''
'''Connection Diagram:'''
 
<br>[[File:19240.png|800px|frameless|thumb]]<br>
<br>[[File:19240.png|500px|frameless|thumb]]<br>
 


'''Sample Code:'''
'''Sample Code:'''
Line 491: Line 486:
<br>[[File:97.png|800px|frameless|thumb]]<br>
<br>[[File:97.png|800px|frameless|thumb]]<br>


<br>
===Project 5: Bluetooth Module===
===Project 5: Bluetooth Module===


<br>[[File:19241.png|500px|frameless|thumb]]<br>
<br>[[File:Ks0192-5.jpg|600px|frameless|thumb]]<br>


'''Introduction:'''
'''Introduction:'''
Line 513: Line 509:
* Supply Voltage: 5V DC 50mA <br>
* Supply Voltage: 5V DC 50mA <br>
* Operating Temperature: -20 to 55℃<br>
* Operating Temperature: -20 to 55℃<br>


'''Connection Diagram:'''
'''Connection Diagram:'''


<br>[[File:19242.png|500px|frameless|thumb]]<br>
<br>[[File:19242.png|800px|frameless|thumb]]<br>


<span style=color:red>Pay more attention that here you must first upload the code to the board and then plug in the Bluetooth module, otherwise the program fails to compile. </span> <br>


'''Sample Code:'''
'''Sample Code:'''
Line 528: Line 524:
Serial.begin(9600);
Serial.begin(9600);
  pinMode(ledpin,OUTPUT);  
  pinMode(ledpin,OUTPUT);  
} void loop()
}
void loop()
{ val=Serial.read();  
{ val=Serial.read();  
if(val=='a')
if(val=='a')
Line 537: Line 534:
delay(250);
delay(250);
  Serial.println("keyestudio");
  Serial.println("keyestudio");
}
}
</pre>
</pre>


Line 544: Line 543:
After power-on, power indicator D1 is on, and LED on Bluetooth module is blinking; open Bluetooth on mobile phone, pair them, input 1234, and finish pairing as shown in Figure 1 ; open APP—Bluetooth serial communication assistant, connect it to Bluetooth, select normal mode, complete connection, and LED on Bluetooth module is on as shown in Figure 2; input an “a” in the assistant, and display “keyestudio” in it as shown in Figure 3.
After power-on, power indicator D1 is on, and LED on Bluetooth module is blinking; open Bluetooth on mobile phone, pair them, input 1234, and finish pairing as shown in Figure 1 ; open APP—Bluetooth serial communication assistant, connect it to Bluetooth, select normal mode, complete connection, and LED on Bluetooth module is on as shown in Figure 2; input an “a” in the assistant, and display “keyestudio” in it as shown in Figure 3.


'''Figure 1:'''  
'''Figure 1:'''-- ---------------------------------'''Figure 2:'''--------------------------- ---------- -------'''Figure 3:'''
<br>[[File:98.png|500px|frameless|thumb]]<br>
<br>[[File:98.png|500px|frameless|thumb]]  [[File:99.png|500px|frameless|thumb]]  [[File:100.png|500px|frameless|thumb]]<br>


'''Figure 2:'''
<br>
<br>[[File:99.png|500px|frameless|thumb]]<br>
 
'''Figure 3:'''
<br>[[File:100.png|500px|frameless|thumb]]<br>


===Project 6: L298N Motor Driver===
===Project 6: L298N Motor Driver===


<br>[[File:19243.png|500px|frameless|thumb]]<br>
<br>[[File:19243.png|600px|frameless|thumb]]<br>


'''Introduction:'''
'''Introduction:'''
Line 579: Line 574:


'''Circuit Connection:'''
'''Circuit Connection:'''
<br>[[File:1001.png|500px|frameless|thumb]]<br>
<br>[[File:1001.png|800px|frameless|thumb]]<br>
<br>[[File:19244.png|500px|frameless|thumb]]<br>
<br>[[File:19244.png|800px|frameless|thumb]]<br>




'''Sample Code:'''
'''Sample Code:'''
<pre>
<pre>
int IN1=5;
int IN2=6;
int IN2=6;
int IN3=7;
int IN3=7;
int IN4=8;
int IN4=8;
int ENA=9;
int ENA=9;
int ENB=10;
int ENB=10;
void setup()
void setup()
{
{
for (int i = 5; i <11; i ++)
for (int i = 5; i <11; i ++)
  {
  {
    pinMode(i, OUTPUT);  
    pinMode(i, OUTPUT);
  }
  }
}
}
void loop()
void loop()
{
{
  // rotate CW
  // rotate CW
 digitalWrite(IN1,LOW);
digitalWrite(IN1,LOW);
 digitalWrite(IN2,HIGH);
digitalWrite(IN2,HIGH);
analogWrite(ENA,200);
analogWrite(ENA,200);
 digitalWrite(IN3,LOW);
digitalWrite(IN3,LOW);
 digitalWrite(IN4,HIGH);
digitalWrite(IN4,HIGH);
analogWrite(ENB,200);
analogWrite(ENB,200);
 delay(1000);
delay(1000);
 // pause for 1S
// pause for 1S
 analogWrite(ENA,0);
analogWrite(ENA,0);
analogWrite(ENB,0);
analogWrite(ENB,0);
 delay(1000);
delay(1000);
 // rotate CCW
// rotate CCW
 digitalWrite(IN1,HIGH);
digitalWrite(IN1,HIGH);
 digitalWrite(IN2,LOW);
digitalWrite(IN2,LOW);
 analogWrite(ENA,100);
analogWrite(ENA,100);
 digitalWrite(IN3,HIGH);
digitalWrite(IN3,HIGH);
 digitalWrite(IN4,LOW);
digitalWrite(IN4,LOW);
analogWrite(ENB,100);
analogWrite(ENB,100);
 delay(1000);
delay(1000);
 // pause for 1S
// pause for 1S
 analogWrite(ENA,0);
analogWrite(ENA,0);
analogWrite(ENB,0);
analogWrite(ENB,0);
 delay(1000);
delay(1000);
}
}
</pre>
</pre>
Line 631: Line 627:
After connection and power-on, two motors rotate clockwise for 1 second at a speed of 200 (PWM value is 200) and then stop for 1 second; two motors rotate anticlockwise for 1 second at a speed of 100 (PWM value is 100) and then stop for 1 second.
After connection and power-on, two motors rotate clockwise for 1 second at a speed of 200 (PWM value is 200) and then stop for 1 second; two motors rotate anticlockwise for 1 second at a speed of 100 (PWM value is 100) and then stop for 1 second.


<br>
===Project 7: keyestudio 1602 I2C Module===
===Project 7: keyestudio 1602 I2C Module===


Line 675: Line 672:


Get libraries of Wire and LiquidCrystal_I2C from:
Get libraries of Wire and LiquidCrystal_I2C from:
 
https://drive.google.com/open?id=15KOCyLn3Wwo-KlCck6hYmm4uiKh0MGrW
http://www.keyestudio.com/files/index/download/id/1479115840/
 


'''Result:'''
'''Result:'''


After connection and uploading codes, keyestudio 1602 I2C module will display as shown in below figure.
After connection and uploading codes, keyestudio 1602 I2C module will display as shown in below figure.
<br>[[File:1003.png|500px|frameless|thumb]]<br>
<br>[[File:1003.png|700px|frameless|thumb]]<br>


<br>
===Project 8: Line Tracking of Smart Car===
===Project 8: Line Tracking of Smart Car===


<br>[[File:1004.png|500px|frameless|thumb]]<br>
<br>[[File:1004.png|600px|frameless|thumb]]<br>


'''Introduction:'''
'''Introduction:'''
Line 701: Line 697:


5.The system is composed of main control circuit, power supply, IR detecting module, motor and driver module. The structure chart of the system is showed by picture 2-1.
5.The system is composed of main control circuit, power supply, IR detecting module, motor and driver module. The structure chart of the system is showed by picture 2-1.
<br>[[File:19248.png|500px|frameless|thumb]]<br>
<br>[[File:19248.png|700px|frameless|thumb]]<br>




'''Schematic Diagram:'''
'''Schematic Diagram:'''
<br>[[File:Ks0192-pro8 原理图.png|500px|frameless|thumb]]<br>
<br>[[File:Ks0192-pro8 原理图.png|700px|frameless|thumb]]<br>




'''Connection Diagram:'''
'''Connection Diagram:'''
<br>[[File:Ks0192-pro8 接线图.png|500px|frameless|thumb]]<br>
<br>[[File:Ks0192-pro8 接线图.png|800px|frameless|thumb]]<br>




Line 878: Line 874:
</pre>
</pre>


<br>
===Project 9: Ultrasonic Obstacle Avoidance of Smart Car===
===Project 9: Ultrasonic Obstacle Avoidance of Smart Car===


<br>[[File:1005.png|500px|frameless|thumb]]<br>
<br>[[File:1005.png|600px|frameless|thumb]]<br>


'''Introduction:'''
'''Introduction:'''
Line 895: Line 892:
'''Schematic Diagram:'''
'''Schematic Diagram:'''


<br>[[File:Ks0192-pro9 原理图.png|500px|frameless|thumb]]<br>
<br>[[File:Ks0192-pro9 原理图.png|700px|frameless|thumb]]<br>




'''Connection Diagram:'''
'''Connection Diagram:'''
<br>[[File:超声波-1.png|500px|frameless|thumb]]<br>
<br>[[File:超声波-1.png|700px|frameless|thumb]]<br>




Line 1,092: Line 1,089:
</pre>
</pre>


<br>
===Project 10: IR Remote Control of Smart Car===
===Project 10: IR Remote Control of Smart Car===


<br>[[File:106.png|500px|frameless|thumb]]<br>
<br>[[File:106.png|600px|frameless|thumb]]<br>


'''Introduction:'''<br>
'''Introduction:'''<br>
Line 1,111: Line 1,109:
'''Schematic Diagram:'''
'''Schematic Diagram:'''


<br>[[File:Ks0192-pro10 原理图.png|500px|frameless|thumb]]<br>
<br>[[File:Ks0192-pro10 原理图.png|700px|frameless|thumb]]<br>




'''Connection Diagram:'''
'''Connection Diagram:'''
<br>[[File:Ks0192-pro10 接线图.png|500px|frameless|thumb]]<br>
<br>[[File:Ks0192-pro10 接线图.png|800px|frameless|thumb]]<br>


'''Sample Code:'''
'''Sample Code:'''
Line 1,279: Line 1,277:
</pre>
</pre>


<br>
===Project 11: Distance Detecting of Smart Car===
===Project 11: Distance Detecting of Smart Car===


<br>[[File:107.png|500px|frameless|thumb]]<br>
<br>[[File:107.png|600px|frameless|thumb]]<br>


'''Introduction:'''
'''Introduction:'''
Line 1,298: Line 1,297:


'''Schematic Diagram:'''
'''Schematic Diagram:'''
<br>[[File:Ks0192-pro11.png|500px|frameless|thumb]]<br>
<br>[[File:Ks0192-pro11.png|800px|frameless|thumb]]<br>




'''Connection Diagram:'''
'''Connection Diagram:'''
<br>[[File:Pro11-距测.png|500px|frameless|thumb]]<br>
<br>[[File:Pro11-距测.png|800px|frameless|thumb]]<br>




Line 1,599: Line 1,598:
}
}
</pre>
</pre>


===Project 12: Bluetooth Remote Control of Smart Car===
===Project 12: Bluetooth Remote Control of Smart Car===


<br>[[File:1008.png|500px|frameless|thumb]]<br>
<br>[[File:1008.png|600px|frameless|thumb]]<br>


'''Introduction:'''
'''Introduction:'''
Line 1,617: Line 1,617:




'''Schematic Diagram:'''
'''Schematic Diagram:'''<br>
<br>[[File:Ks0192-pro12 原理图.png|500px|frameless|thumb]]<br>
<span style=color:red> Pay more attention that here you must first upload the code to the board and then plug in the Bluetooth module, otherwise the program fails to compile. </span> <br>
<br>[[File:Ks0192-pro12 原理图.png|700px|frameless|thumb]]<br>




'''Connection Diagram:'''
'''Connection Diagram:'''
<br>[[File:Ks0192-pro12 接线图.png|500px|frameless|thumb]]<br>
<br>[[File:Ks0192-pro12 接线图.png|700px|frameless|thumb]]<br>




Line 1,759: Line 1,760:
}
}
</pre>
</pre>
<br>


===Project 13: 5 in 1 Muilti-functional Car (Line Tracking, Obstacle Avoidance, Bluetooth and IR Remote Control, Distance Detecting) ===
===Project 13: 5 in 1 Muilti-functional Car (Line Tracking, Obstacle Avoidance, Bluetooth and IR Remote Control, Distance Detecting) ===


<br>[[File:1009.png|500px|frameless|thumb]]<br>
<br>[[File:1009.png|600px|frameless|thumb]]<br>


'''Introduction:'''
'''Introduction:'''
Line 1,770: Line 1,773:


'''Schematic Diagram:'''
'''Schematic Diagram:'''
<br>[[File:Ks0192-pro13-.jpg|500px|frameless|thumb]]<br>
<br>[[File:Ks0192-pro13-.jpg|800px|frameless|thumb]]<br>




'''Connection Diagram:'''
'''Connection Diagram:'''
<br>[[File:5 in 1 - 副本-.jpg|500px|frameless|thumb]]<br>
<br>[[File:5 in 1 - 副本-.jpg|800px|frameless|thumb]]<br>




Line 2,267: Line 2,270:
Number 1 and 2 key control rotation of motor, while 3 and 4 key control move speed. Reset again, the car goes into Bluetooth mode. If connecting to Bluetooth APP, you can control the motion of the car by APP.
Number 1 and 2 key control rotation of motor, while 3 and 4 key control move speed. Reset again, the car goes into Bluetooth mode. If connecting to Bluetooth APP, you can control the motion of the car by APP.


<br>
==Resources ==
==Resources ==


'''Assembly Video:'''
'''Download Bluetooth APP, Test Code and Libraries:'''


http://www.keyestudio.com/wp/2016/11/ks0192-keyestudio-4wd-bluetooth-multi-functional-car-assembly-video-2/
https://fs.keyestudio.com/KS0192


'''Demons Video:'''
'''Assembly Video:'''<br>
https://video.keyestudio.com/KS0192/


http://www.keyestudio.com/wp/2016/11/ks0192-keyestudio-4wd-bluetooth-multi-functional-car-demonstration-video/
'''Demons Video:'''<br>
https://video.keyestudio.com/KS0192/


'''PDF: '''


https://drive.google.com/open?id=1h0NWFRa3xaREiqjwnlnDkOPBgmF0PV7f


'''APP: '''
<br>


https://drive.google.com/open?id=19CRygKifT-0FIFU78DFn2XRGz0atxMWe
==Buy from ==
 
'''Codes: '''
 
https://drive.google.com/open?id=1Azrqy0uBILycGlOiknPNMHXu1Ser2_Dk
 
'''Libraries:'''


https://drive.google.com/open?id=15KOCyLn3Wwo-KlCck6hYmm4uiKh0MGrW
*[https://www.keyestudio.com/keyestudio-4wd-bluetooth-multi-functional-diy-smart-car-for-arduino-robot-education-programminguser-manualpdfonlinevideo-p0393-p0393.html    '''Official Website''']


==Buy from ==
*[https://www.amazon.com/keyestudio-Bluetooth-Multi-functional-Starter-Arduino/dp/B01N9HV6ZH/  '''Shop on Amazon''']
'''Official Website'''


http://www.keyestudio.com/keyestudio-4wd-bluetooth-multi-functional-car.html


'''Amazon Store'''


https://www.amazon.com/keyestudio-Bluetooth-Multi-functional-Starter-Arduino/dp/B01N9HV6ZH/ref=sr_1_1?s=toys-and-games&ie=UTF8&qid=1486963013&sr=1-1&keywords=Ks0192+keyestudio+4WD+Bluetooth+Multi-functional+Car


[[Category: Smart Car]]
[[Category: Smart Car]]

Latest revision as of 11:19, 6 January 2021

Introduction

keyestudio 4WD Bluetooth Multi-functional Car is a learning application development system based on microcontroller and with ATmega-328 as core. It has functions of line tracking, obstacle avoidance, IR remote control, Bluetooth remote control and distance detection. This kit contains plenty of interesting programs and can extend an external circuit module to increase more functions of this car. The kit aims to disengage users from boring theories and obtain capacity of system development when they are learning Arduino .


Parameters

  • 1.Motor: Voltage: 6-9V Reduction Ratio: 1:48
  • 2.Choosing L298N driver module l as control motor, separated from microcontrollor
  • 3.Three line tracking modules, having higher precision when detecting white and black lines,able to realize anti-falling
  • 4.IR remote control module making up a remote control system of the car
  • 5.Using ultrasonic module to realize obstacle avoidance
  • 6.Pairing mobile phone Bluetooth with Bluetooth remote control module to control the car
  • 7.Able to connect with external voltage at 7~12V,and equipped with various sensors to complete different functions as much as possible


Component List

No. Product Name Quantity Picture
1 keyestudio UNO R3 1
thumb
2 keyestudio Shield V5 1
thumb
3 keyestudio L298N Motor Shield 1
thumb
4 keyestudio Bluetooh HC-06 1
thumb
5 I2C 1602 LCD 1
thumb
6 keyestudio Line Tracking Sensor 3
thumb
7 HC-SR04 Ultrasonic Sensor 1
thumb
8 keyestudio Digital IR Receiver Module 1
thumb
9 4WD Top PCB 1
thumb
10 4WD Bottom PCB 1
thumb
11 Servo Motor 1
thumb
12 Servo Plastic Platform 1
thumb
13 Remote Control of Chip 1
thumb
14 Toggle Switch + Wire 1 thumb
15 18650 Battery Holder 1 thumb
16 Mental Motor 4 thumbthumbthumbthumb
17 Motor Fixed Part 4 thumbthumbthumbthumb
18 Plastic Tire 4 thumbthumbthumbthumb
19 Copper Pillar 40MM 6
thumb
20 Copper Pillar 10MM 16
thumb
21 USB Cable 1
thumb
22 Dupont Line 30
thumb
23 M3*6MM Round Head Screw 60
thumb
24 M3*8MM Flat Head Screw 2 thumbthumb
25 M3*30MM Round Head Screw 8 thumbthumbthumbthumbthumbthumbthumbthumb
26 3MM Nut 16
thumb
27 Connector Wire (150mm, Black) 6
thumb
28 Connector Wire (150mm, Red) 6
thumb
29 Winding Wire (12CM) 1
thumb


Project List

Project 1:Line Tracking Sensor
Project 2:Ultrasonic Sensor
Project 3:Digital IR Receiver Module
  Project 4:Servo Motor
Project 5:Bluetooth Module
Project 6:L298N Motor Driver
Project 7:I2C 1602 LCD
Project 8:Line Tracking of Smart Car
Project 9:Obstacle Avoidance of Smart Car
Project 10:IR Remote Control of Smart Car
Project 11:Distance Detecting of Smart Car
Project 12:Bluetooth Remote Control of Smart Car
Project 13:5 in 1 Muilti-functional Car


Address of Assembly Video

http://video.keyestudio.com/ks0192/


Address of Demonstration Video

http://www.keyestudio.com/wp/2016/09/ks0192-keyestudio-4wd-bluetooth-multi-functional-car-demonstration-video/


Project Details

Project 1: Line Tracking Sensor


thumb

Introduction:

This Line Tracking Sensor can detect white lines in black and black lines in white. The single line-tracking signal provides a stable output signal TTL for a more accurate and more stable line. Multi-channel option can be easily achieved by installing required line-tracking robot sensors.

Specification:

  • Power Supply: +5V
  • Operating Current: <10mA
  • Operating Temperature Range: 0°C ~ + 50°C
  • Output Interface: 3-wire interface (1 - signal, 2 - power, 3 - power supply negative)
  • Output Level: TTL level

Connection Diagram:


thumb


Sample Code:

const int sensorPin = 3;     // the number of the sensor pin
const int ledPin =  13;      // the number of the LED pin
int sensorState = 0;         // variable for reading the sensor status
void setup() {
  pinMode(ledPin, OUTPUT);      
  pinMode(sensorPin, INPUT); }
void loop(){
  // read the state of the sensor value:
  sensorState = digitalRead(sensorPin);
  // if the sensorState is HIGH:
  if (sensorState == HIGH) {     
     digitalWrite(ledPin, HIGH);  
  } 
  else {digitalWrite(ledPin, LOW); 
  }}


Result:

After power-on, power indicator D1 is on. When you block the sensing part of line tracking sensor with black paper, LED on the sensor is off as shown in Figure 1. When you block it with white paper, LED is on as shown in Figure 2.

Figure 1:
thumb

Figure 2:
thumb



Project 2: Ultrasonic Sensor


thumb

Introduction:
The HC-SR04 Ultrasonic Sensor is a very affordable proximity/distance sensor that has been used mainly for object avoidance in various robotics projects. It essentially gives your Arduino eyes/ spacial awareness and can prevent your robot from crashing or falling off a table. It has also been used in turret applications, water level sensing, and even as a parking sensor. This simple project will use the HC-SR04 sensor with an Arduino and a processing sketch to provide a neat little interactive display on your computer screen.

Specification:

  • Working Voltage: DC 5V
  • Working Current: 15mA
  • Working Frequency: 40Hz
  • Max Range: 4m
  • Min Range: 2cm
  • Measuring Angle: 15 degree
  • Trigger Input Signal: 10µS TTL pulse
  • Echo Output Signal Input TTL lever signal and the range in proportion
  • Size: 46*20.4mm
  • Weight: 9g

Connection Diagram:


thumb

Sample Code:

VCC to arduino 5v
GND to arduino GND
Echo to Arduino pin 7
Trig to Arduino pin 8

 
#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin
#define LEDPin 13 // Onboard LED

int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}

void loop() {
/* The following trigPin/echoPin cycle is used to determine the
 distance of the nearest object by bouncing soundwaves off of it. */ 
 digitalWrite(trigPin, LOW); 
 delayMicroseconds(2); 

 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10); 
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 
 //Calculate the distance (in cm) based on the speed of sound.
 distance = duration/58.2;
 
 if (distance >= maximumRange || distance <= minimumRange){
 /* Send a negative number to computer and Turn LED ON 
 to indicate "out of range" */
 Serial.println("-1");
 digitalWrite(LEDPin, HIGH); 
 }
 else {
 /* Send the distance to the computer using Serial protocol, and
 turn LED OFF to indicate successful reading. */
 Serial.println(distance);
 digitalWrite(LEDPin, LOW); 
 } 
 //Delay 50ms before next reading.
 delay(50);
}


Result:
After connection and uploading, when ultrasonic sensor senses obstacle within sensing area, it is measuring the distance between itself and obstacle and the value of distance is displayed on serial monitor as shown in below figure.
thumb


Project 3: Digital IR Receiver Module


thumb

Introduction:
IR is widely used in remote control. With this IR receiver , Arduino project is able to receive command from any IR remoter controller if you have the right decoder. Well, it will be easy to make your own IR controller using IR transmitter.

Specification:

  • Power Supply: 5V
  • Interface: Digital
  • Modulate Frequency: 38Khz
  • Module Interface Socket: JST PH2.0

NOTE: In the sample code below Digital pin 11 is in use, you may either change your wiring or change the sample code to match. 

Connection Diagram: 


thumb


Sample Code:

#include <IRremote.h>
 int RECV_PIN = 11;
 IRrecv irrecv(RECV_PIN);
 decode_results results;
 void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}
 void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}

IR Remote Library includes some sample codes for sending and receiving.

https://github.com/shirriff/Arduino-IRremote

Result: In this project, we need to use a IR remote control which has 17 functional key and its launching distance is 8 meters at most, proper to control various devices indoors. This project is actually to decode remote control signal. After connection and uploading codes, aim at IR receiving module and press the key, finally you can see the corresponding codes. If you press the key too long, it will show messy codes easily as shown in below figure.
thumb

thumb


Project 4: Servo Motor


thumb

Introduction:

Servomotor is a position control rotary actuator. It mainly consists of housing, circuit board, core-less motor, gear and position sensor. The receiver or MCU outputs a signal to the servomotor. The motor has a built-in reference circuit that gives out reference signal, cycle of 20ms and width of 1.5ms. The motor compares the acquired DC bias voltage to the voltage of the potentiometer and outputs a voltage difference. The IC on the circuit board will decide the rotate direction accordingly and drive the core-less motor. The gear then passes the force to the shaft. The sensor will determine if it has reached the commanded position according to the feedback signal. Servomotors are used in control systems that require to have and maintain different angles. When the motor speed is definite, the gear will cause the potentiometer to rotate. When the voltage difference reduces to zero, the motor stops. Normally, the rotation angle range is among 0-180 degrees.

Servomotor comes with many specifications. But all of them have three connection wires, distinguished by brown, red, orange color(different brand may have different color). Brown one is for GND, red one for power positive, orange one for signal Line.


thumb

The rotating angle of the servo motor is controlled by regulating the duty cycle of the PWM(Pulse-Width Modulation) signal. The standard cycle of the PWM signal is 20ms(50Hz). Theoretically, the width is distributed between 1ms-2ms, but in fact, it's between 0.5ms-2.5ms. The width corresponds the rotate angle from 0° to 180°. But note that for different brand motor, the same signal may have different rotating angle. 


thumb

Mastering some basic knowledge, let's learn how to control a servomotor. In this experiment, you only need a servomotor and several jumper wires. 


Connection & Sample Program:
There are two ways to control a servomotor with Arduino. One is to use a common digital sensor port of Arduino to produce square wave with different duty cycle to simulate PWM signal and then use that signal to control the positioning of the motor. Another way is to directly use the Servo function of the Arduino to control the motor. In this way, the program will be more easier but it can only control two-contact motor because of the servo function, only digital pin 9 and 10 can be used. The Arduino drive capacity is limited. So if you need to control more than one motor, you will need external power.

Connection Diagram:
thumb

Sample Code:

int servopin=9;// select digital pin 9 for servomotor signal line
int myangle;// initialize angle variable
int pulsewidth;// initialize width variable
int val;
void servopulse(int servopin,int myangle)// define a servo pulse function
{
pulsewidth=(myangle*11)+500;// convert angle to 500-2480 pulse width
digitalWrite(servopin,HIGH);// set the level of servo pin as “high”
delayMicroseconds(pulsewidth);// delay microsecond of pulse width
digitalWrite(servopin,LOW);// set the level of servo pin as “low”
delay(20-pulsewidth/1000);
}
void setup()
{
pinMode(servopin,OUTPUT);// set servo pin as “output”
Serial.begin(9600);// connect to serial port, set baud rate at “9600”
Serial.println("servo=o_seral_simple ready" ) ;
}
void loop()// convert number 0 to 9 to corresponding 0-180 degree angle, LED blinks corresponding number of time
{
val=Serial.read();// read serial port value
if(val>'0'&&val<='9')
{
val=val-'0';// convert characteristic quantity to numerical variable
val=val*(180/9);// convert number to angle
Serial.print("moving servo to ");
Serial.print(val,DEC);
Serial.println();
for(int i=0;i<=50;i++) // giving the servo time to rotate to commanded position
{
servopulse(servopin,val);// use the pulse function
}
}
}


Result:
When you input a number on serial monitor, the motor rotates to an angle which is equal to the number input, and the angle value will be displayed on screen, as shown in below figure.
thumb


Project 5: Bluetooth Module


thumb

Introduction:

This Bluetooth module can easily achieve serial wireless data transmission. Its operating frequency is among the most popular 2.4GHz ISM frequency band (i.e. Industrial, scientific and medical). It adopts Bluetooth 2.1+EDR standard. In Bluetooth 2.1, signal transmit time of different devices stands at a 0.5 seconds interval so that the workload of bluetooth chip can be reduced substantially and more sleeping time can be saved for bluetooth. This module is set with serial interface, which is easy-to-use and simplifying overall design/development cycle.


Specification:

  • Bluetooth Protocol: Bluetooth 2.1+ EDR Standard
  • USB Protocol: USB v1.1/2.0
  • Operating Frequency: 2.4GHz ISM Frequency Band
  • Modulation Mode: Gauss Frequency Shift Keying
  • Transmit Power: ≤ 4dBm, Second Stage
  • Sensitivity: ≤-84dBm at 0.1% Bit Error Rate
  • Transmission Speed: 2.1Mbps(Max)/160 kbps(Asynchronous); 1Mbps/1Mbps(Synchronous)
  • Safety Feature: Authentication and Encryption
  • Supported Configuration: Bluetooth Serial Port (major and minor)
  • Supply Voltage: 5V DC 50mA
  • Operating Temperature: -20 to 55℃

Connection Diagram:


thumb

Pay more attention that here you must first upload the code to the board and then plug in the Bluetooth module, otherwise the program fails to compile.

Sample Code:

int val; 
int ledpin=13; 
void setup() 
{ 
Serial.begin(9600);
 pinMode(ledpin,OUTPUT); 
}
 void loop()
{ val=Serial.read(); 
if(val=='a')
 { 
digitalWrite(ledpin,HIGH); 
delay(250); 
digitalWrite(ledpin,LOW); 
delay(250);
 Serial.println("keyestudio");
}
}


Result:

After power-on, power indicator D1 is on, and LED on Bluetooth module is blinking; open Bluetooth on mobile phone, pair them, input 1234, and finish pairing as shown in Figure 1 ; open APP—Bluetooth serial communication assistant, connect it to Bluetooth, select normal mode, complete connection, and LED on Bluetooth module is on as shown in Figure 2; input an “a” in the assistant, and display “keyestudio” in it as shown in Figure 3.

Figure 1:-- ---------------------------------Figure 2:--------------------------- ---------- -------Figure 3:
thumb thumb thumb


Project 6: L298N Motor Driver


thumb

Introduction:

Using L298N made by ST Company as the control chip, the module has characteristics of strong driving ability, low calorific value and strong anti-interference ability.
This module can use built-in 78M05 for electric work via a driving power supply part. But to avoid the damage of the voltage stabilizing chip, please use an external 5V logic supply when using more than 12V driving voltage.
Using large capacity filter capacitor, this module can follow current to protect diodes, and improve reliability.


Specification:

  • Working Mode: H bridge (double lines)
  • Control Chip: L298N (ST)
  • Logical Voltage: 5V
  • Driving Voltage: 5V-35V
  • Logical Current: 0mA-36mA
  • Driving Current: 2A (MAX single bridge)
  • Storage Temperature: (-20 °C)-(+135 °C)
  • Maximum Power: 25W
  • Weight: 30g
  • Periphery Dimension: 43 x 43 x 27 mm(L x W x H)


Circuit Connection:
thumb

thumb


Sample Code:

int IN1=5;
int IN2=6;
int IN3=7;
int IN4=8;
int ENA=9;
int ENB=10;
void setup()
{
for (int i = 5; i <11; i ++)
  {
    pinMode(i, OUTPUT);  
  }
}
void loop()
{
  // rotate CW
 digitalWrite(IN1,LOW);
 digitalWrite(IN2,HIGH);
analogWrite(ENA,200);
 digitalWrite(IN3,LOW);
 digitalWrite(IN4,HIGH);
analogWrite(ENB,200);
 delay(1000);
 // pause for 1S
 analogWrite(ENA,0);
analogWrite(ENB,0);
 delay(1000);
 // rotate CCW
 digitalWrite(IN1,HIGH);
 digitalWrite(IN2,LOW);
 analogWrite(ENA,100);
 digitalWrite(IN3,HIGH);
 digitalWrite(IN4,LOW);
analogWrite(ENB,100);
 delay(1000);
 // pause for 1S
 analogWrite(ENA,0);
analogWrite(ENB,0);
 delay(1000);
}


Result:

After connection and power-on, two motors rotate clockwise for 1 second at a speed of 200 (PWM value is 200) and then stop for 1 second; two motors rotate anticlockwise for 1 second at a speed of 100 (PWM value is 100) and then stop for 1 second.


Project 7: keyestudio 1602 I2C Module


thumb thumb
Introduction:
This is great LCD display compatible with arduino. With limited pin resources, your project will quickly run out of resources using normal LCDs. With this I2C interface LCD module, you only need 2 lines (I2C)to display the information.If you already have I2C devices in your project, this LCD module actually costs no more resources at all. The address can be set 0x27.

Specification:

  • I2C Address: 0x27
  • Back Lit (Blue with white char color)
  • Supply Voltage: 5V
  • Interface:I2C/TWI x1,Gadgeteer interface x2
  • Adjustable Contrast
  • Size:82x35x18 mm


Connection Diagram:

I602 is equipped with 4 pins in total. SCL should be connected to analog 5, SDA to analog 4, VCC to +5V and GND to ground.
thumb

Sample Code:

//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(3,0);
lcd.print("Hello, world!");
lcd.setCursor(2,1);
lcd.print("keyestudio!");
}
void loop()
{}

Get libraries of Wire and LiquidCrystal_I2C from: https://drive.google.com/open?id=15KOCyLn3Wwo-KlCck6hYmm4uiKh0MGrW

Result:

After connection and uploading codes, keyestudio 1602 I2C module will display as shown in below figure.
thumb


Project 8: Line Tracking of Smart Car


thumb

Introduction:

This project introduces a simple and automatic line tracking system of a car based on Arduino microcontroller.This car,regarding UNO as main control, detects black line by IR photoelectric sensor and send the feedback to Arduino. Arduino will analyze the feedback signal and then control the driver motor to adjust the car diversion. Finally the car is able to go around the black line automatically. In addition, you can observe the state of the car through keyestudio 1602 I2C module.

Principle:

1.Black absorbs most light. When the panel isn’t black, most IR emitted by the sensor is reflected back. So the sensor outputs low level at 0.
2.When there is a sensor above black line, since reflectivity of black is small,little IR is reflected back under demand that the sensor works. Therefore, the sensor output 1.
3.We just need to know the output of the sensor is 1 or 0 with Arduino to detect black line.
4.Arduino controls the motion of the car according to received signal. The system scheme is showed by the following picture 1-1.

thumb

5.The system is composed of main control circuit, power supply, IR detecting module, motor and driver module. The structure chart of the system is showed by picture 2-1.
thumb


Schematic Diagram:
thumb


Connection Diagram:
thumb


Sample Code:

#include <LiquidCrystal_I2C.h> 
#include <Wire.h> 
#define SensorLeft    6   //input pin of left sensor
#define SensorMiddle  9   //input pin of middle sensor
#define SensorRight   11   //input pin of right sensor
unsigned char SL;        //state of left sensor
unsigned char SM;        //state of middle sensor
unsigned char SR;        //state of right sensor
#define Lpwm_pin  5     //pin of controlling speed---- ENA of motor driver board
#define Rpwm_pin  10    //pin of controlling speed---- ENA of motor driver board
int pinLB=2;            //pin of controlling diversion----IN1 of motor driver board
int pinLF=4;            //pin of controlling diversion----IN2 of motor driver board
int pinRB=7;            //pin of controlling diversion----IN3 of motor driver board
int pinRF=8;            //pin of controlling diversion----IN4 of motor driver board
unsigned char Lpwm_val =180;//the speed of left wheel at 180 in initialization
unsigned char Rpwm_val = 180;//the speed of right wheel at 180 in initialization
int Car_state=0;             //state of car moving
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 
void LCD1602_init(void)
{
  lcd.init();                     
  lcd.backlight(); 
  lcd.clear();  
}
void Sensor_IO_Config()
{
  pinMode(SensorLeft,INPUT);
  pinMode(SensorMiddle,INPUT);
  pinMode(SensorRight,INPUT);
}
void Sensor_Scan(void)
{
  SL = digitalRead(SensorLeft);
  SM = digitalRead(SensorMiddle);
  SR = digitalRead(SensorRight);
}
void M_Control_IO_config(void)//initialized function of IO of motor driver
{
  pinMode(pinLB,OUTPUT); // pin 2--IN1 of motor driver board
  pinMode(pinLF,OUTPUT); // pin 4--IN2 of motor driver board
  pinMode(pinRB,OUTPUT); // pin 7--IN3 of motor driver board
  pinMode(pinRF,OUTPUT); // pin 8--IN4 of motor driver board
  pinMode(Lpwm_pin,OUTPUT); // pin 5  (PWM) --ENA of motor driver board
  pinMode(Rpwm_pin,OUTPUT); // pin 10 (PWM) --ENB of motor driver board  
}
void Set_Speed(unsigned char Left,unsigned char Right)//setting function of speed
{
  analogWrite(Lpwm_pin,Left);   
  analogWrite(Rpwm_pin,Right);
}
void advance()     // going forwards
    {
     digitalWrite(pinRB,LOW);  // making motor move towards right rear
     digitalWrite(pinRF,HIGH);
     digitalWrite(pinLB,LOW);  //  making motor move towards left rear
     digitalWrite(pinLF,HIGH); 
     Car_state = 1; 
     show_state();   
    }
void turnR()        //turning on the right(dual wheels)
    {
     digitalWrite(pinRB,LOW);  //making motor move towards right rear
     digitalWrite(pinRF,HIGH);
     digitalWrite(pinLB,HIGH);
     digitalWrite(pinLF,LOW);  //making motor move towards left front
     Car_state = 4;
     show_state();
    }
void turnL()        //turning on the left(dual wheels)
    {
     digitalWrite(pinRB,HIGH);
     digitalWrite(pinRF,LOW );   //making motor move towards right front
     digitalWrite(pinLB,LOW);   //making motor move towards left rear
     digitalWrite(pinLF,HIGH);
     Car_state = 3;
     show_state();
    }    
void stopp()         //stop
    {
     digitalWrite(pinRB,HIGH);
     digitalWrite(pinRF,HIGH);
     digitalWrite(pinLB,HIGH);
     digitalWrite(pinLF,HIGH);
     Car_state = 5;
     show_state();
    }
void back()          //back
    {
     digitalWrite(pinRB,HIGH);  //making motor move towards right rear
     digitalWrite(pinRF,LOW);
     digitalWrite(pinLB,HIGH);  //making motor move towards left rear
     digitalWrite(pinLF,LOW);
     Car_state = 2;
     show_state() ;    
    }
void show_state(void)  //showing current state of the car
{
  lcd.setCursor(0, 1); //showing from second row
   switch(Car_state)
   {
     case 1:lcd.print(" Go  ");Serial.print("\n GO");
     break;
     case 2:lcd.print("Back ");Serial.print("\n Back");
     break;
     case 3:lcd.print("Left ");Serial.print("\n Left");
     break;
     case 4:lcd.print("Right");Serial.print("\n Right");
     break;
     case 5:lcd.print("Stop ");Serial.print("\n Stop"); 
     break;
     default:
     break;
   }
}
void setup() 
{ 
   LCD1602_init();
   Sensor_IO_Config();
   M_Control_IO_config();        //motor controlling the initialization of IO
   Set_Speed(Lpwm_val,Rpwm_val); //setting initialization of speed
   lcd.clear();
   lcd.setCursor(0, 0);  //cursor set in first row and first column,
   lcd.print("  Wait  Signal  ");
   stopp();
} 
unsigned char old_SL,old_SM,old_SR;
void loop() 
{ 
  Sensor_Scan();
 if (SM == HIGH)// middle sensor in black area
{
if (SL == LOW & SR == HIGH) // black on left, white on right, turn left
{
turnR();
}
else if (SR == LOW & SL == HIGH) // white on left, black on right, turn right
{
turnL();
}
else // white on both sides, going forward
{
advance();
}
}
else // middle sensor on white area
{
if (SL== LOW & SR == HIGH)// black on left, white on right, turn left
{
turnR();
}
else if (SR == LOW & SL == HIGH) // white on left, black on right, turn right
{
turnL();
}
else // all white, stop
{
back();
delay(100);
stopp() ; 
}
}
} 


Project 9: Ultrasonic Obstacle Avoidance of Smart Car


thumb

Introduction:

This project,regarding Arduino UNO as main control, is to detect front obstacle by ultrasonic sensor and platform motor, and send the feedback to Arduino. Arduino will analyze the feedback signal and then control the driver motor to adjust the car diversion. Finally, the car is able to avoid obstacle automatically and to keep going.

Principle:

1.Ultrasonic detecting distance: one port emits high level more than 10 US. Once outputting level, open potentiometer to time. When the port becomes low level, read out current value. Use the time of detecting distance to calculate distance.
2.Use ultrasonic to detect the distance between obstacle and car, so that control the motion of the car according to the data.
3.If the distance between the car and obstacle is less than 20 cm, the car goes backward; if the distance is no less than 40 cm, the car goes