指導老師:陳若貞 專題學生:陳佑昇 中 華 民 國 107 年 6 月

27
防撞智能車 指導老師:陳若貞 專題學生:陳佑昇 1 0 7 6

Upload: others

Post on 24-Jul-2022

6 views

Category:

Documents


0 download

TRANSCRIPT




1 0 7 6
I

2.1.2 Arduino .......................................................................................... 3
2.3 HC-SR04 ............................................................................. 6
3.2 ....................................................................................................... 11
3.3 ............................................................................................................ 12
.............................................................................................. 20
......................................................................................... 21
2.3 Arduino ........................................................................................ 4
2.4 L298N ......................................................................................... 5
2.6 ..................................................................................... 7
4.1 .............................................................................................................. 20
4.2 .............................................................................................................. 21
2.2 L298N ...................................................................... 5
2.3HC-SR04 .......................................................................................... 7
Arduino (Single-Board Microcontroller)

Simple IO WindowsMac OS X Linux
JavaC ProcessingWiring [1]
Arduino
[1]
Arduino Uno ATmega328 14 IO
6 analogWrite() 8-bit PWM 6
16 MHz40mABootloader
USB
2
SDA SCL
USB

Microcontroller ATmega328
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 32 KB (ATmega328) of which 0.5 KB used by
bootloader
Uno R3 CC

4
New
5
L298N I/O 1
1 8 12 3
4 5 5V
Arduino UNO 67 Enable bridge IC
IC Enable bridge On
Off L298N 8 4 Arduino UNO 1
[5]
L298N

Logic Supply Voltage +5~+7
Peak Current 2
Operating Current 0~36
Maximum Power 20
6

Arduino PWM Motor A

EAN=H
IN1= IN2 Motor A
EAN=L --- Motor A
(H = L =)
2.3 HC-SR04
20kHz
[6]
42KHz [7]
7
2cm-400cm
2.3HC-SR04 [9]
Working Current 15mA
Working Frequency 40kHz
Max Range 4cm
Min Range 2cm
(Echo Output Signa) Input TTL lever signal and the range
in proportion
340 1000000
340 × 100 = 29.4 microseconds
[8]
I/O

9


3.2 Arduino
12
#define EchoPin A0 // A0
#define TrigPin A1 // A1
#define EchoPinL A2 // A2
#define TrigPinL A3 // A3
#define EchoPinR A4 // A4
#define TrigPinR A5 // A5
#define F_ang 90 //
#define R_ang 30 //
#define L_ang 150 //
int Fspeedd = 0; //
int Rspeedd = 0; //
int Lspeedd = 0; //
int directionn = 0; // =8 =2 =4 =6
int Fgo = 8; //
int Rgo = 6; //
int Lgo = 4; //
int Bgo = 2; //
pinMode(motorIn1, OUTPUT);
pinMode(motorIn2, OUTPUT);
pinMode(motorIn3, OUTPUT);
pinMode(motorIn4, OUTPUT);
Serial.begin(9600);
delay(250);
myservo.detach();
{
{
{
μs
delayMicroseconds(10);
digitalWrite(TrigPinL, LOW); // 2μs
μs
delayMicroseconds(10);
digitalWrite(TrigPinR, LOW); // 2μs
μs
delayMicroseconds(10);
16
if (ang == F_ang)
Serial.print(distance); //
Serial.println(distanceR); //
Lspeedd = distanceL;
Rspeedd = distanceR;


2017 11 4 2017






[5]http://designer.mech.yzu.edu.tw/articlesystem/article/compressedfile/(2013-02-18)
%20%E4%BD%BF%E7%94%A8%E9%A6%AC%E9%81%94%E9%A9%85%E5%
8B%95IC%E6%90%AD%E9%85%8DArduino%20Uno%E6%8E%A7%E5%88%B6
%E9%A6%AC%E9%81%94%E8%BC%B8%E5%87%BA.pdf
HC-SR04
[6]https://zh.wikipedia.org/wiki/%E8%B6%85%E8%81%B2%E6%B3%A2
[7]http://yhhuang1966.blogspot.com/2016/10/arduino.html
[8]http://coopermaa2nd.blogspot.tw/2012/09/hc-sr04.html
[9]https://www.electroschematics.com/8902/hc-sr04-datasheet/
[10]http://atceiling.blogspot.com/2017/03/arduino_28.html
[11] https://yunlinsong.blogspot.com/2016/11/mblock_18.html