KS0507 Keyestudio Smart RV Kit: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
Line 400: Line 400:
PWM mostly is used for adjusting the LED brightness or rotation speed of motor.<br>
PWM mostly is used for adjusting the LED brightness or rotation speed of motor.<br>
It plays vital role in controlling smart robot car. I believe that you can’t wait to enter next project.<br>
It plays vital role in controlling smart robot car. I believe that you can’t wait to enter next project.<br>
(7) Extension Practice:
Let’s keep pins unchanged and change the delay value, then observe how LED changes.<br>

Revision as of 10:26, 11 March 2021


thumb

About keyestudio

Keyestudio is a best-selling brand owned by KEYES Corporation. Our product lines range from controller boards, shields and sensor modules to smart car and complete starter kits for Arduino, Raspberry Pi and BBC micro:bit, which can help customers at any level learn electronics and programming knowledge. Likewise, all of our products comply with international quality standards and are greatly appreciated in a variety of different markets throughout the world.
You can obtain the details and the latest information through visiting the following web sites:http://www.keyestudio.com


References and After-sales Service

1.Download Profile:https://fs.keyestudio.com/KS0507
2.Feel free to contact us please, if there is missing part or you encounter some troubles. Welcome to send email to us:service@keyestudio.com. We will update projects and products continuously from your sincere advice.


Warning

1.This product contains tiny parts(screws, copper pillars), keep it out of reach of children under 7 years old please.
2.This product contains conductive parts (control board and electronic module). Please operate according to the requirements of tutorial. Improper operation may cause parts to overheat damage. Do not touch and immediately disconnect the circuit power.

Copyright

The keyestudio trademark and logo are the copyright of KEYES DIY ROBOT co.,LTD. All products under Keyestudio brand can’t be copied, sold and resold without authorization by anyone or company. If you’re interested in our items, please contact to our sales representatives: fennie@keyestudio.com


Description:

When it comes to programming, many think it difficult. However, KEYES group issues a smart RV kit to cope with this problem.
This is low cost, easy-to-build and open source programming kit-----smart RV.
It integrates smart home and robot car. In addition, it helps you absorb the knowledge of programming like electronics, control logic and computing and science.
In compliance with the tutorial, you can create your own robot by boards, slot connection and wiring. In the assembly process, the detailed projects will guide you to learn the working principle of sensors and modules.
What’s more, it a has temperature humidity sensor and an LCD display except LED, line tracking sensor, ultrasonic sensor, Bluetooth module and motor driving modules.
Should you are interested in STEM and code programming, you can customize your RV by altering code and adding extra modules. That sounds entertaining, right? Let’s get started1

Features

  • Multi-purpose function:obstacle avoidance, line tracking, Bluetooth control, ultrasonic follow, smart sensation and so on.
  • Easy to build:Slot connection and without soldering circuit
  • Novel style:Adopt strong wood board, acrylic board, RGB and lcd1602 modules.
  • High extension:configure motor driving chip, preserve IIC, UART and SPI port and expand other sensor and module.
  • Basic programming learning:use C language and code

Specification:

  • Working voltage: 5v
  • Input voltage: 7-12V
  • Maximum output current: 3A
  • Maximum power dissipation: 15W
  • Motor speed: 200 rpm (4.5V)
  • Motor driving form: TB6612 chip drive
  • Ultrasonic sensing angle: <15 degrees
  • Ultrasonic detection distance: 2cm-400cm
  • Bluetooth remote control distance: 50 meters (measured)
  • Bluetooth APP control: support Android and iOS system


Kit

Remember to check if the components received are in line with the following product list when you getting this kit.


thumb

thumb

thumb

thumb

thumb

thumb

thumb

thumb

thumb


Getting Started with Arduino

Installing Arduino IDE

When we get control board, we need to download Arduino IDE and driver firstly. You could download Arduino IDE from the official website:
https://www.arduino.cc/, click the SOFTWARE on the browse bar, click“DOWNLOADS” to enter download page, as shown below:


thumb

You can download either Windows win7 and newer or Windows ZIP file.
The first one doesn’t require

There are two versions of IDE for WINDOWS system, you can choose from the Installer (.exe) and the Zip packages. We suggest you use the first one that installs directly everything you need to use the Arduino Software (IDE), including the drivers.
With the Zip package you need to install the drivers manually. The Zip file is also useful if you want to create a portable installation.


thumb

thumb

You just need to click JUST DOWNLOAD.

Keyestudio MEGA 2560 Smart Development Board

We need to know keyestudio MEGA 2560 development board, as a core of this smart car.


thumb

The processor core of MEGA 2560 board is ATMEGA2560-16AU, with the cp2102 chip.
It has 54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, 1 ICSP header, and a reset button.
It can be interfaced computer with external power with a USB cable.


thumb

thumb

Install Driver on Windows System

Let’s install the driver of keyestudio MEGA 2560 smart development board. The USB-TTL chip on this board adopts CP2102 serial chip. The driver program of this chip is included in Arduino 1.8 version and above, which is convenient. Plugged in USB port, the computer can recognize the hardware and automatically install the driver of CP2102.

If install unsuccessfully, or you intend to install manually, open the device manager of computer. Right click Computer----- Properties----- Device Manager.


thumb

There is a yellow exclamation mark on the page, which implies installing unsuccessfully. Then we double click the hardware and update the driver.


thumb

Click “OK” to enter the following page, click“browse my computer for updated driver software”, find out the installed or downloaded ARDUINO software. As shown below:


thumb

There is a DRIVERS folder in Arduino software installed package. Just open driver folder and you can see the driver of CP210X series chips.


We click “Browse”, then find out the driver folder, or you could enter “driver” to search in rectangular box, then click“next”, the driver will be installed successfully. (I place Arduino software folder on the desktop, you can follow my way)


thumb

thumb

Open device manager, we will find the yellow exclamation mark disappear. The driver of CP2102 is installed successfully.


thumb

Install Driver on MAC System

The USB to serial chip of control board is CP2102. We install driver on MAC as follows: https://wiki.keyestudio.com/How_to_Install_the_Driver_of_CP2102_on_MAC_System


Arduino IDE Setting

Click0486-12.png icon,open Arduino IDE.


0507--25.png


To avoid the errors when uploading the program to the board, you need to select the correct Arduino board that matches the board connected to your computer. Then come back to the Arduino software, you should click Tools→Board, select the board. (as shown below)


0507--26.png


Then select the correct COM port (you can see the corresponding COM port after the driver is successfully installed)


0507-22.png

0507--28.png

Before uploading the program to the board, let’s demonstrate the function of each symbol in the Arduino IDE toolbar.


0507--29.png


  • A- Used to verify whether there is any compiling mistakes or not.
  • B- Used to upload the sketch to your Arduino board.
  • C- Used to create shortcut window of a new sketch.
  • D- Used to directly open an example sketch.
  • E- Used to save the sketch.
  • F- Used to send the serial data received from board to the serial monitor.


Note: the setting method on Mac system is same as on Windows system except different COM port, as shown below:


0497=图片8.png

Start First Program

We’ve known how to download and install the driver of development board , next, we will burn a code to show“Hello World!”in the monitor.

Test Code


void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);   
}

void loop() {
  // print out "Hello world!"
  Serial.println("Hello world!");
  delay(1000);// delay 1 second
}


Open Arduino IDE, and set board as follows:


0507--31.png


Set COM port, as shown below:


0507--32.png

Click 0486-20.png to start compiling the program, and check errors.
Click 0486-23.png to upload the program, upload successfully.


0507--33.png

Upload the program successfully, open serial monitor and set baud rate to 9600. Monitor will print“Hello World!”each 1s.
Congratulation, you finish the first program.


0507--34.png


Projects

For detailed projects, nevigated the website https://fs.keyestudio.com/KS0507


The whole project begins with basic program. Starting from simple to complex, the lessons will guide you to assemble smart RV and absorb the knowledge of electronic and machinery step by step. I reckon that you might hardly sit still and itch to have a go, let’s get started.

Note: (G), marked on each sensor and module, is negative pole and connected to“G”,“-”or“GND”on the sensor shield or control board ; (V) is positive pole and interfaced with“V”,“VCC”,“+”or“5V”on the sensor shield or control board.

Project 1: LED Blink

(1)Description:


0507--1.png

For the starter and enthusiast, this is a fundamental program---LED Blink. LED, the abbreviation of light emitting diodes, consist of Ga, As, P, N chemical compound and so on. It is often applied to numbers and text display as an indicator in the circuit.

The LED can flash diverse color by altering the delay time in the test code. When in control, power on GND and VCC, the LED will be on if S end is high level; nevertheless, it will go off.

(2) Parameter:


0507--2.png 0507--3.png

  • Control interface: digital port
  • Working voltage: DC 3.3-5V
  • Pin spacing: 2.54mm
  • LED display color: red


(3) Component:


0507--4.png

(4)Connection Diagram:


0507--5.png

From the above diagram, pin -, + and S of LED module are respectively connected to pin G, 5V and D13 of expansion board. Then we compile the code as follows:


(5)Test Code:

  /*
  keyestudio smart RV
  lesson 1.1
  Blink
  http://www.keyestudio.com
*/
#define LED  13 //define the pin of LED as D13
void setup()
{
  pinMode(LED, OUTPUT);// initialize digital pin LED as an output.
}
void loop() // the loop function runs over and over again forever
{
  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level
  delay(1000);    // wait for a second
  digitalWrite(LED, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);    // wait for a second
}
//*******************************************************************


(6)Test Result:

Upload the program, LED blinks with the interval of 1s.

(7)Code Explanation:

pinMode(LED,OUTPUT) - This function can denote that the pin is INPUT or OUTPUT.
digitalWrite(LED,HIGH) - When pin is OUTPUT, we can set it to HIGH(output 5V) or LOW(output 0V).

(8)Extension Practice:
The LED flashes for 1s through the test result, therefore, pins and delay time affect flash frequency.

/*
  keyestudio smart RV
  lesson 1.2
  Blink
  http://www.keyestudio.com
*/
#define LED 13 //Define the pin of LED as D13
void setup()
{
  pinMode(LED, OUTPUT);// initialize digital pin LED as an output.
}
void loop() // the loop function runs over and over again forever
{
  digitalWrite(LED, HIGH);   // turn LED on (HIGH is the voltage level
  delay(100);    // wait for a second
  digitalWrite(LED, LOW);    // turn LED off by making the voltage LOW
  delay(100);    // wait for a second
}
//****************************************************************

The LED flashes faster through the lesson 1.2 test.

Project 2: Adjust LED Brightness

(1)Description: In previous lesson, we control LED on and off and make it blink. In this project, we will control LED brightness through PWM to simulate breathing effect. Similarly, you can change the step length and delay time in the code so as to demonstrate different breathing effect.

PWM is a means of controlling the analog output via digital means. Digital control is used to generate square waves with different duty cycles (a signal that constantly switches between high and low levels) to control the analog output.In general, the input voltage of port are 0V and 5V. What if the 3V is required? Or what if switch among 1V, 3V and 3.5V? We can’t change resistor constantly. For this situation, we need to control by PWM.


thumb
For the Arduino digital port voltage output, there are only LOW and HIGH, which correspond to the voltage output of 0V and 5V. You can define LOW as 0 and HIGH as 1, and let the Arduino output five hundred 0 or 1 signals within 1 second.
If output five hundred 1, that is 5V; if all of which is 1, that is 0V. If output 010101010101 in this way then the output port is 2.5V, which is like showing movie. The movie we watch are not completely continuous. It actually outputs 25 pictures per second. In this case, the human can’t tell it, neither does PWM. If want different voltage, need to control the ratio of 0 and 1. The more 0,1 signals output per unit time, the more accurately control.
(2)Component:

thumb
(3)Connection Diagram:
We keep connection diagram unchanged.

thumb
(4)Test Code:

/*
  keyestudio smart RV
  lesson 2.1
  PWM
  http://www.keyestudio.com
*/
#define LED 13 //Define the pin of LED as D13
int value;
void setup()
{
  pinMode(LED, OUTPUT);// initialize digital pin LED as an output.
}
void loop () {
  for (value = 0; value < 255; value = value + 1) {
    analogWrite (LED, value); // LED lights gradually light up
    delay (5); // delay 5MS
  }
  for (value = 255; value > 0; value = value - 1) {
    analogWrite (LED, value); // LED gradually goes out
    delay (5); // delay 5MS
  }
}

(5) Test Result:
Upload test code successfully, LED gradually becomes brighter then darker, like human breath.

(6) Code Explanation When we need to repeat some statements, we could use FOR statement. FOR statement format is shown below:


thumb
FOR cyclic sequence:
Round 1:1 → 2 → 3 → 4
Round 2:2 → 3 → 4 …
Until number 2 is not established, “for”loop is over, After knowing this order, go back to code:

for (int value = 0; value < 255; value=value+1){

       ...}

for (int value = 255; value >0; value=value-1){

      ...}


The two“for”statements make value increase from 0 to 255, then reduce from 255 to 0, then increase to 255,....infinitely loop There is a new function in the following ----- analogWrite()
We know that digital port only has two state of 0 and 1. So how to send an analog value to a digital value? Here,this function is needed. Let’s observe the Arduino board and find 6 pins marked“~”which can output PWM signals.
Function format as follows:

analogWrite(pin,value)
analogWrite() is used to write an analog value from 0~255 for PWM port, so the value is in the range of 0~255. Attention that you only write the digital pins with PWM function, such as pin 3, 5, 6, 9, 10, 11.
PWM is a technology to obtain analog quantity through digital method. Digital control forms a square wave, and the square wave signal only has two states of turning on and off (that is, high or low levels). By controlling the ratio of the duration of turning on and off, a voltage varying from 0 to 5V can be simulated. The time turning on(academically referred to as high level) is called pulse width, so PWM is also called pulse width modulation.
Through the following five square waves, let’s acknowledge more about PWM.

thumb


In the above figure, the green line represents a period, and value of analogWrite() corresponds to a percentage which is called Duty Cycle as well. Duty cycle implies that high-level duration is divided by low-level duration in a cycle. From top to bottom, the duty cycle of first square wave is 0% and its corresponding value is 0. The LED brightness is lowest, that is, turn off. The more time high level lasts, the brighter the LED. Therefore, the last duty cycle is 100%, which correspond to 255, LED is brightest. 25% means darker.
PWM mostly is used for adjusting the LED brightness or rotation speed of motor.
It plays vital role in controlling smart robot car. I believe that you can’t wait to enter next project.

(7) Extension Practice: Let’s keep pins unchanged and change the delay value, then observe how LED changes.