LAFVIN Obstacle Avoidance Smart Car Kit Скачать руководство пользователя страница 43

41/78

gle line comments start with // and everything up until the end of that line is considered a comment.
The first line of code is:

int led = 13;

As the comment above it explains, this is giving a name to the pin that the LED is attached to. This is 13 on most Arduinos, including the
UNO and Leonardo.
Next, we have the 'setup' function. Again, as the comment says, this is executed when the reset button is pressed. It is also executed
whenever the board resets for any reason, such as power first being applied to it, or after a sketch has been uploaded.

void setup() {
// initialize the digital pin as an output.

pinMode(led, OUTPUT);

}

Every Arduino sketch must have a 'setup' function, and the place where you might want to add instructions of your own is between the
{ and the }.
In this case, there is just one command there, which, as the comment states tells the Arduino board that we are going to use the LED pin
as an output.
It is also mandatory for a sketch to have a 'loop' function. Unlike the 'setup' function that only runs once, after a reset, the 'loop' function
will, after it has finished running its commands, immediately start again.

void loop() { digitalWrite(led, HIGH); delay(1000); digitalWrite(led, LOW);

delay(1000);

}

Inside the loop function, the commands first of all turn the LED pin on (HIGH), then 'delay' for 1000 milliseconds (1 second), then turn
the LED pin off and pause for another second.

// turn the LED on (HIGH is the voltage

level) // wait for a second

Содержание Obstacle Avoidance Smart Car Kit

Страница 1: ...Obstacle Avoidance Smart Car Kit...

Страница 2: ......

Страница 3: ...n 2 Add Libraries and Open Serial Monitor 20 Lesson 3 Blink 32 Lesson 4 Installation Method 43 Lesson 5 Servo 54 Lesson 6 Ultrasonic Sensor Module 57 Lesson 7 IR Receiver Module 62 Lesson 8 L298N Moto...

Страница 4: ...We are cooperating with a lot of companies from diffirent countries Also help them to purchase electronic component products in china and became the biggest supplier of them We look forward to build c...

Страница 5: ...utorial This tutorial include codes labraries and lessons It is designed for beginners It will teach every users how to assembly the smart robot car kit and use Arduino controller board sensors and mo...

Страница 6: ...4 78 Packing list...

Страница 7: ...The Arduino software that you will use to program your Arduino is available for Windows Mac and Linux The installation process is different for all three platforms and unfortunately there is a certai...

Страница 8: ...6 78 STEP2 Download the development software that is compatible with the operating system of your computer Take Windows as an example here...

Страница 9: ...7 78 Click Windows Installer Click JUST DOWNLOAD...

Страница 10: ...sion 1 8 0 is available in the material we provided and the versions of our materials are the latest versions when this course was made Installing Arduino Windows Install Arduino with the exe Installa...

Страница 11: ...9 78 Click I Agree to see the following interface...

Страница 12: ...10 78 Click Next You can press Browse to choose an installation path or directly type in the directory you want...

Страница 13: ...11 78 Click Install to initiate installation Finally the following interface appears click Install to finish the installation...

Страница 14: ...12 78 Next the following icon appears on the desktop Double click to enter the desired development environment...

Страница 15: ...d skip the contents below and jump to the next section But if you want to learn some methods other than the installation package please continue to read the section Unzip the zip file downloaded Doubl...

Страница 16: ...14 78...

Страница 17: ...he LED will light up and you may get a Found New Hardware message from Windows Ignore this message and cancel any attempts that Windows makes to try and install drivers automatically for you The most...

Страница 18: ...16 78 Right click on the device and select the top menu option Update Driver Software...

Страница 19: ...78 You will then be prompted to either Search Automatically for updated driver software or Browse my computer for driver software Select the option to browse and navigate to the X arduino1 8 0 driver...

Страница 20: ...llow the software to be installed Once the software has been installed you will get a confirmation message Windows users may skip the installation directions for Mac and Linux systems and jump to Less...

Страница 21: ...will ask you to install Java runtime library if you don t have it in your computer Once the installation is complete you can run the Arduino IDE Installing Arduino Linux You will have to use the make...

Страница 22: ...For example the built in LiquidCrystal library makes it easy to talk to character LCD displays There are hundreds of additional libraries available on the Internet for download The built in libraries...

Страница 23: ...we will install the Bridge library Scroll the list to find it then select the version of the library you want to install Sometimes only one version of the library is available If the version selection...

Страница 24: ...vailable in the Include Library menu If you want to add your own library open a new issue on Github Importing a zip Library Libraries are often distributed as a ZIP file or folder The name of the fold...

Страница 25: ...IDE navigate to Sketch Include Library At the top of the drop down list select the option to Add ZIP Library You will be prompted to select the library you would like to add Navigate to the zip file s...

Страница 26: ...24 78...

Страница 27: ...Manual installation To install the library first quit the Arduino application Then uncompress the ZIP file containing the library For example if you re installing a library called ArduinoParty uncomp...

Страница 28: ...p and h files just make sure they re all there The library won t work if you put the cpp and h files directly into the libraries folder or if they re nested in an extra folder For example Documents Ar...

Страница 29: ...ided to include a serial terminal with the software Within the Arduino environment this is called the Serial Monitor Making a Connection Serial monitor comes with any and all version of the Arduino ID...

Страница 30: ...which port to open in the Serial Monitor is the same as selecting a port for uploading Arduino code Go to Tools Serial Port and select the correct port Tips Choose the same COM port that you have in...

Страница 31: ...29 78 Once open you should see something like this...

Страница 32: ...ndle most of your serial communication needs The first setting you can alter is the baud rate Click on the baud rate drop down menu to select the correct baud rate 9600 baud Last you can set the termi...

Страница 33: ...connection with your Arduino If you re already working in the Arduino IDE there s really no need to open up a separate terminal to display data Cons The lack of settings leaves much to be desired in...

Страница 34: ...Fistly you need to download and intall UNO CH340G driver The UNO R3 board has rows of connectors along both sides that are used to connect to several electronic devices and plug in shields that exten...

Страница 35: ...which it blinks In Lesson 0 you set up your Arduino IDE and made sure that you could find the right serial port for it to connect to your UNO R3 board The time has now come to put that connection to...

Страница 36: ...34 78 When the sketch window opens enlarge it so that you can see the entire sketch in the window...

Страница 37: ...upload them to an UNO R3 board but if you change them you cannot save them as the same file Since we are going to change this sketch the first thing you need to do is save your own copy From the File...

Страница 38: ...36 78 You have saved your copy of Blink in your sketchbook This means that if you ever want to find it again you can just open it using the File Sketchbook menu option...

Страница 39: ...37 78 Attach your Arduino board to your computer with the USB cable and check that the Board Type and Serial Port are set correctly...

Страница 40: ...it could be COM3 or COM4 on your computer A right COM port is supposed to be COMX arduino XXX which is by the certification criteria The Arduino IDE will show you the current settings for board at th...

Страница 41: ...n the Arduino should start to flicker as the sketch is transferred Finally the staus will change to Done The other message tells us that the sketch is using 928 bytes of the 32 256 bytes available Aft...

Страница 42: ...check your installation Once the upload has completed the board should restart and start blinking Open the code Note that a huge part of this sketch is composed of comments These are not actual progr...

Страница 43: ...PUT Every Arduino sketch must have a setup function and the place where you might want to add instructions of your own is between the and the In this case there is just one command there which as the...

Страница 44: ...the parameter in for the delay command This delay period is in milliseconds so if you want the LED to blink twice as fast change the value from 1000 to 500 This would then pause for half a second each...

Страница 45: ...43 78 Lesson 4 Installation Method...

Страница 46: ...44 78...

Страница 47: ...45 78...

Страница 48: ...46 78...

Страница 49: ...47 78...

Страница 50: ...48 78...

Страница 51: ...49 78...

Страница 52: ...50 78...

Страница 53: ...51 78...

Страница 54: ...52 78...

Страница 55: ...53 78...

Страница 56: ...re As simple as that Servo motors were first used in the Remote Control RC world usually to control the steering of RC cars or the flaps on a RC plane With time they found their uses in robotics autom...

Страница 57: ...55 78 Connection diagram...

Страница 58: ...onto your Arduino board See Lesson 3 for details about program uploading if there are any errors Before you can run this make sure that you have installed the Servo library or re install it if necess...

Страница 59: ...itters receiver and control circuit The basic principle of work 1 Using IO trigger for at least 10us high level signal 2 The Module automatically sends eight 40 kHz and detect whether there is a pulse...

Страница 60: ...the time interval between sending trigger signal and receiving echo signal Formula us 58 centimeters or us 148 inch or the range high level time velocity 340M S 2 we suggest to use over 60ms measureme...

Страница 61: ...59 78 Wiring diagram...

Страница 62: ...the sensor After wiring please open the program in the code folder Lesson 6 Ultrasonic Sensor Module and click UPLOAD to upload the program See Lesson 3 for details about program uploading if there ar...

Страница 63: ...61 78 Open the monitor then you can see the data as blow Click the Serial Monitor button to turn on the serial monitor The basics about the serial monitor are introduced in details in Lesson 1...

Страница 64: ...ibrary that was designed for this particular sensor 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...

Страница 65: ...63 78 Wiring diagram...

Страница 66: ...erwise your code won t work For details about loading the library file see Lesson 3 In this lessson we need to use a IR remote control which has 17 functional key and its launching distance is 8 meter...

Страница 67: ...65 78 Remote control code...

Страница 68: ...contains two complete H Bridge circuits so it is capable of driving a pair of DC motors This makes it ideal for robotic projects as most robots have either two or four powered wheels The L298N can als...

Страница 69: ...nterference 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...

Страница 70: ...68 78 Wiring diagram...

Страница 71: ...See Lesson 3 for details about program uploading if there are any errors After connection and power on two motors rotate clockwise for 2 second at a speed of 200 PWM value is 200 and then stop for 2 s...

Страница 72: ...controller as main control uses IR module to receive IR remote signal and send the signal to Arduino Arduino will analyses the signal and then control the driver motor and the motion of the car with I...

Страница 73: ...71 78 Connection Schematic...

Страница 74: ...72 78 Wiring diagram...

Страница 75: ...lick UPLOAD to upload the program See Lesson 3 for details about program uploading if there are any errors Before you can run this make sure that you have installed the IRremote library or re install...

Страница 76: ...motor and send the feedback to Arduino Arduino will analyses the feedback signal and then control the driver motor to adjust the car diversion Finally the car is able to avoid obstacle automatically...

Страница 77: ...e between the car and obstacle is less than 35 cm the car goes backward if the distance is no less than 10 cm the car goes forwards if the distance is less than 60 cm the motor turns to detect the dis...

Страница 78: ...76 78 Connection Schematic...

Страница 79: ...77 78 Wiring diagram...

Страница 80: ...ick UPLOAD to upload the program See Lesson 2 for details about program uploading if there are any errors Before you can run this make sure that you have installed the Servo HC SR04 library or re inst...

Отзывы: