Arduino Smart Car Production report

Source: Internet
Author: User
Tags rewind

Arduino Smart Car Production report production members: 20135224 Chen Shi 20135208 He Bong 20135207 Wang Gui Prerequisites:

Arduino, an open-source, single-board controller, is built on the open source simple I/O interface and has a processing wiring development environment that uses a similar java,c language, using a software and hardware platform based on open-sourced code. Choose Arduino as the control Board of the Smart car, because it is small but powerful, can be convenient and sensors and a variety of electronic components connected, but also with a lot of software such as flash, processing connection interaction, but the most important is its open source features, Its circuit design and the IDE are open source, everyone can be free to modify and use, which is now the Arduino can become popular reason, what is more than the freedom to share their own production more attractive! (Introduction of video teaching materials)

Production line: 1 understand the necessary car installation Knowledge 2 Install the necessary program software 3 Learn video tutorial 4 Install the CAR Hardware Section 5 familiar with the software tools use 6 View Code and burn code process 7 Inspection Trolley Finish Quality

First, to understand the necessary knowledge of the car installation

Related books

Recommended from Baidu

It is said that these are the books of the legendary level, for we can only be tasted

Second, install the necessary program software

Installing Arduino development Software Arduino-1.0.5-windows

Three, learn video tutorial

Most of the problems in the video can be explained in a good adjustment of their own machine

Four, install the car hardware part

To install the car specific order:

Motor---battery box---universal wheel---Expansion of bread board---Aircraft gimbal---Development Board

Attention to detail details:

1 motor in the installation of note two screws can not be tightened too tight, so as not to put the second one in

2 In addition to the battery, the other device is fixed to prevent the car from shaking while walking, the motor power according to the card buckle direction is inserted

3 LCD screen More attention to order, similar to the diode and transistor connection, in the digital mode has mentioned

4 when the car to bake the program when the car state to pay attention to

5 Potentiometer control by the various functions of the specific representation, in the commissioning can be based on the light difference between the judge of the program function

Production process:

Five, familiar with the use of software tools

Run interface

The basic ability is:

The hook is the compile program

The arrow to the right is the compiler and the programming program.

The top right corner is used when using ultrasound to detect accurate data.

You can see the accuracy of the data hours

VI, view code and burn code flow

Generally by small programs to build a large operation of the process, because the implementation function code is encapsulated, some functions to implement a guessing component

First understand the General Foundation construction, the forward operation code:

Forward:

int left_motor_back=8; Left motor back (IN1)
int left_motor_go=9; Left Motor forward (IN2)

int right_motor_go=10; Right motor forward (IN3)
int right_motor_back=11; Right motor back (IN4)

void Setup ()
{
Initialize the motor drive IO as the output mode
Pinmode (Left_motor_go,output); PIN 8 (PWM)
Pinmode (Left_motor_back,output); PIN 9 (PWM)
Pinmode (right_motor_go,output);//PIN (PWM)
Pinmode (right_motor_back,output);//PIN One (PWM)
}
void run (int time)//forward
{
Digitalwrite (Right_motor_go,high); Right Motor forward
Digitalwrite (Right_motor_back,low);
Analogwrite (right_motor_go,200);//pwm proportional 0~255 speed adjustment, left and right wheel difference slightly increase or decrease
Analogwrite (right_motor_back,0);
Digitalwrite (Left_motor_go,high); Left Motor forward
Digitalwrite (Left_motor_back,low);
Analogwrite (left_motor_go,200);//pwm proportional 0~255 speed adjustment, left and right wheel difference slightly increase or decrease
Analogwrite (left_motor_back,0);
Delay (time * 100); Execution time, can be adjusted
}

void Loop ()
{
Delay (500);
Run (10); Forward
}

-----------------------------------------------------------------

Compound before and after:

int left_motor_back=8; Left motor back (IN1)
int left_motor_go=9; Left Motor forward (IN2)

int right_motor_go=10; Right motor forward (IN3)
int right_motor_back=11; Right motor back (IN4)

void Setup ()
{
Initialize the motor drive IO as the output mode
Pinmode (Left_motor_go,output); PIN 8 (PWM)
Pinmode (Left_motor_back,output); PIN 9 (PWM)
Pinmode (right_motor_go,output);//PIN (PWM)
Pinmode (right_motor_back,output);//PIN One (PWM)
}
void run (int time)//forward
{
Digitalwrite (Right_motor_go,high); Right Motor forward
Digitalwrite (Right_motor_back,low);
Analogwrite (right_motor_go,200);//pwm proportional 0~255 speed adjustment, left and right wheel difference slightly increase or decrease
Analogwrite (right_motor_back,0);
Digitalwrite (Left_motor_go,high); Left Motor forward
Digitalwrite (Left_motor_back,low);
Analogwrite (left_motor_go,200);//pwm proportional 0~255 speed adjustment, left and right wheel difference slightly increase or decrease
Analogwrite (left_motor_back,0);
Delay (time * 100); Execution time, can be adjusted
}

void brake (int time)//brake, parking
{
Digitalwrite (Right_motor_go,low);
Digitalwrite (Right_motor_back,low);
Digitalwrite (Left_motor_go,low);
Digitalwrite (Left_motor_back,low);
Delay (time * 100);//execution times, can be adjusted
}

void left (int time)//Right Turn (the revolver does not move.
{
Digitalwrite (Right_motor_go,high);//Right motor forward
Digitalwrite (Right_motor_back,low);
Analogwrite (right_motor_go,200);
Analogwrite (right_motor_back,0);//PWM proportional 0~255 speed regulation
Digitalwrite (Left_motor_go,low); The revolver doesn't move.
Digitalwrite (Left_motor_back,low);
Analogwrite (left_motor_go,0);
Analogwrite (left_motor_back,0);//PWM proportional 0~255 speed regulation
Delay (time * 100);//execution times, can be adjusted
}

void Spin_left (int time)//left (revolver back, right wheel forward)
{
Digitalwrite (Right_motor_go,high);//Right motor forward
Digitalwrite (Right_motor_back,low);
Analogwrite (right_motor_go,200);
Analogwrite (right_motor_back,0);//PWM proportional 0~255 speed regulation
Digitalwrite (Left_motor_go,low); Revolver back
Digitalwrite (Left_motor_back,high);
Analogwrite (left_motor_go,0);
Analogwrite (left_motor_back,200);//PWM proportional 0~255 speed regulation
Delay (time * 100);//execution times, can be adjusted
}

void right (int time)//R-Turn (right wheel fixed, revolver forward)
{
Digitalwrite (Right_motor_go,low); Right motor does not move
Digitalwrite (Right_motor_back,low);
Analogwrite (right_motor_go,0);
Analogwrite (right_motor_back,0);//PWM proportional 0~255 speed regulation
Digitalwrite (Left_motor_go,high);//Left Motor forward
Digitalwrite (Left_motor_back,low);
Analogwrite (left_motor_go,200);
Analogwrite (left_motor_back,0);//PWM proportional 0~255 speed regulation
Delay (time * 100);//execution times, can be adjusted
}

void spin_right (int time)//Right Turn (right wheel back, revolver forward)
{
Digitalwrite (Right_motor_go,low); Right Motor back
Digitalwrite (Right_motor_back,high);
Analogwrite (right_motor_go,0);
Analogwrite (right_motor_back,200);//PWM proportional 0~255 speed regulation
Digitalwrite (Left_motor_go,high);//Left Motor forward
Digitalwrite (Left_motor_back,low);
Analogwrite (left_motor_go,200);
Analogwrite (left_motor_back,0);//PWM proportional 0~255 speed regulation
Delay (time * 100);//execution times, can be adjusted
}

void back (int time)//Rewind
{
Digitalwrite (Right_motor_go,low); Right Wheel back
Digitalwrite (Right_motor_back,high);
Analogwrite (right_motor_go,0);
Analogwrite (right_motor_back,150);//PWM proportional 0~255 speed regulation
Digitalwrite (Left_motor_go,low); Revolver back
Digitalwrite (Left_motor_back,high);
Analogwrite (left_motor_go,0);
Analogwrite (left_motor_back,150);//PWM proportional 0~255 speed regulation
Delay (time * 100); Execution time, can be adjusted
}

void Loop ()
{
Delay (2000); Delay 2s after start
Back (10); Back 1s
Brake (5);//Stop 0.5s
Run (10);//forward 1s
Brake (5);//Stop 0.5s
Left (10);//turn to 1s
Right (10);//turn left 1s
Spin_right (20); Rotate Right 2s
Spin_left (20);//rotate Left 2s
Brake (5);//Parking
}

The first 2 pieces of code comparison can be found: is the forward function of the time to adjust to the back or left or right

The implementation of the left and right should be realized by the speed difference, and the speed can be realized from the function of supplying the voltage

---------------------------------------------------------------------------

Subsequent code:

#include <Servo.h>
int left_motor_back=8; Left motor back (IN1)
int left_motor_go=9; Left Motor forward (IN2)
int right_motor_go=10; Right motor forward (IN3)
int right_motor_back=11; Right motor back (IN4)

int key=7;//defines the key number 7 interface
int beep=12;//define buzzer Digital 12 interface

const int sensorright = 3; Right tracking infrared sensor (P3.2 OUT1)
const int sensorleft = 4; Left tracking infrared sensor (P3.3 OUT2)

int SL; Left Tracking infrared sensor status
int SR; Right Tracking infrared sensor status

void Setup ()
{
Initialize the motor drive IO as the output mode
Pinmode (Left_motor_go,output); PIN 8 (PWM)
Pinmode (Left_motor_back,output); PIN 9 (PWM)
Pinmode (right_motor_go,output);//PIN (PWM)
Pinmode (right_motor_back,output);//PIN One (PWM)
Pinmode (key,input);//define the key interface as the input interface
Pinmode (Beep,output);
Pinmode (Sensorright, INPUT); Define right trace infrared sensor as input
Pinmode (Sensorleft, INPUT); Define left trace infrared sensor as input
}

-----------------------------------------------------------

Infrared function:

#include <irremote.h>//contains infrared libraries
int recv_pin = a4;//Port declaration
Irrecv irrecv (Recv_pin);
DECODE_RESULTS results;//Structure Declaration
int on = 0;//flag bit
unsigned long last = Millis ();

Long Run_car = 0x00ff18e7;//Key 2
Long Back_car = 0x00ff4ab5;//Key 8
Long Left_car = 0x00ff10ef;//Key 4
Long Right_car = 0x00ff5aa5;//Key 6
Long Stop_car = 0x00ff38c7;//Key 5
Long Left_turn = 0x00ff30cf;//Key 1
Long Right_turn = 0x00ff7a85;//Key 3
//==============================
int left_motor_back=8; Left motor back (IN1)
int left_motor_go=9; Left Motor forward (IN2)

int right_motor_go=10; Right motor forward (IN3)
int right_motor_back=11; Right motor back (IN4)

Void Setup ()
{
//Initialize motor drive IO as output mode
Pinmode (left_motor_go,output);//PIN 8 (PWM)
Pinmode (left_motor_ Back,output); Pin 9 (PWM)
Pinmode (right_motor_go,output),//PIN (PWM)
Pinmode (right_motor_back,output);//PIN One (PWM)
Pinmode (output),////port mode, output
Serial.begin (9600);//baud rate 9600
Irrecv.enableirin ();//Start the receiver
}
Void Run ()//forward
{
Digitalwrite (Right_motor_go,high);//Right Motor forward
Digitalwrite (Right_motor_back,low);
//analogwrite (right_motor_go,200),//PWM ratio 0~255 speed, left and right wheel difference slightly increase or decrease
//analogwrite (right_motor_back,0);
Digitalwrite (Left_motor_go,high); Left Motor forward
Digitalwrite (left_motor_back,low);
//analogwrite (left_motor_go,200)//PWM proportional 0~255 speed adjustment, left and right wheel difference slightly increase or decrease
/ /analogwrite (left_motor_back,0);
//delay (time * 100);//execution times, can be adjusted
}

void brake ()//brakes, parking
{
Digitalwrite (Right_motor_go,low);
Digitalwrite (Right_motor_back,low);
Digitalwrite (Left_motor_go,low);
Digitalwrite (Left_motor_back,low);
Delay (time * 100);//execution times, can be adjusted
}

void left ()//Ieft (revolver not moving, right wheel forward)
{
Digitalwrite (Right_motor_go,high);//Right motor forward
Digitalwrite (Right_motor_back,low);
Analogwrite (right_motor_go,200);
Analogwrite (right_motor_back,0);//PWM proportional 0~255 speed regulation
Digitalwrite (Left_motor_go,low); The revolver doesn't move.
Digitalwrite (Left_motor_back,low);
Analogwrite (left_motor_go,0);
Analogwrite (left_motor_back,0);//PWM proportional 0~255 speed regulation
Delay (time * 100);//execution times, can be adjusted
}

void Spin_left ()//left (revolver back, right wheel forward)
{
Digitalwrite (Right_motor_go,high);//Right motor forward
Digitalwrite (Right_motor_back,low);
Analogwrite (right_motor_go,200);
Analogwrite (right_motor_back,0);//PWM proportional 0~255 speed regulation
Digitalwrite (Left_motor_go,low); Revolver back
Digitalwrite (Left_motor_back,high);
Analogwrite (left_motor_go,0);
Analogwrite (left_motor_back,200);//PWM proportional 0~255 speed regulation
Delay (time * 100);//execution times, can be adjusted
}

void right ()//Left turn (right wheel fixed, revolver forward)
{
Digitalwrite (Right_motor_go,low); Right motor does not move
Digitalwrite (Right_motor_back,low);
Analogwrite (right_motor_go,0);
Analogwrite (right_motor_back,0);//PWM proportional 0~255 speed regulation
Digitalwrite (Left_motor_go,high);//Left Motor forward
Digitalwrite (Left_motor_back,low);
Analogwrite (left_motor_go,200);
Analogwrite (left_motor_back,0);//PWM proportional 0~255 speed regulation
Delay (time * 100);//execution times, can be adjusted
}

void Spin_right ()//Right Turn (right wheel back, revolver forward)
{
Digitalwrite (Right_motor_go,low); Right Motor back
Digitalwrite (Right_motor_back,high);
Analogwrite (right_motor_go,0);
Analogwrite (right_motor_back,200);//PWM proportional 0~255 speed regulation
Digitalwrite (Left_motor_go,high);//Left Motor forward
Digitalwrite (Left_motor_back,low);
Analogwrite (left_motor_go,200);
Analogwrite (left_motor_back,0);//PWM proportional 0~255 speed regulation
Delay (time * 100);//execution times, can be adjusted
}

void back ()//Rewind
{
Digitalwrite (Right_motor_go,low); Right Wheel back
Digitalwrite (Right_motor_back,high);
Analogwrite (right_motor_go,0);
Analogwrite (right_motor_back,150);//PWM proportional 0~255 speed regulation
Digitalwrite (Left_motor_go,low); Revolver back
Digitalwrite (Left_motor_back,high);
Analogwrite (left_motor_go,0);
Analogwrite (left_motor_back,150);//PWM proportional 0~255 speed regulation
Delay (time * 100); Execution time, can be adjusted
}

Void dump (decode_results *results)
{
int count = Results->rawlen;
if (Results->decode_type = = UNKNOWN)
{
//serial.println ("Could not decode message");
Brake ();
}

void Loop ()
{
if (Irrecv.decode (&results))//Call library function: Decode
{
If it ' s been at least second since the last
IR received, toggle the relay
if (Millis ()-Last > 250)//Confirm received signal
{
On =!on;//Flag position counter
Digitalwrite, on? High:low);//The board receives a signal flashing LEDs
Dump (&results);//decoding infrared signal
}
if (Results.value = = Run_car)//Key 2
Run ();//forward
if (Results.value = = Back_car)//Key 8
Back ();//Backward
if (Results.value = = Left_car)//Key 4
Left ();
if (Results.value = = Right_car)//Key 6
Right ();//Turn Left
if (Results.value = = Stop_car)//Key 5
Brake ();//Parking
if (Results.value = = Left_turn)//Key 1
Spin_left ();//left rotation
if (Results.value = = Right_turn)//Key 3
Spin_right ();//Right rotation
Last = Millis ();
Irrecv.resume (); Receive the next value
}
}

Can be found: as long as the implementation function on the front and rear to add control signals, the use of if or Swich and other options to implement the program's jump

Burn: connect the line and use the software to check in.

Seven, test the car to complete the quality

Insufficient car:

There are many bad actions in the operation

1 The car around the direction of rotation imbalance, which is difficult to avoid many factors

2 car for some obstacles can not be judged: transparent, too low, left and right corner of the

3 There is no prediction, when the speed adjustment is too fast, there will be no response to the phenomenon

Practice Summary:

1 through this practice, not only to test our hands-on ability, but also to improve our understanding of the way code action to drive specific actions.

2 A diversified understanding of the way of learning: the end of the paper, a lot of things do not have to read to understand, hands is also an indispensable way

3 ability to improve the performance: Understanding ability, learning ability, hands-on ability and so on a variety of ability to promote is self-evident, which in the future of our study and life are very good teaching materials and bedding

4 There is no better only better consciousness: excellence is our guiding ideology, the car's shortcomings for us may also be an indispensable power it

Arduino Smart Car Production report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.