กลับไปหน้ารวมไฟล์
easiest-bluetooth-car-using-arduino-and-mit-app-inventor-4e5622.md

รถบังคับ Bluetooth ที่ง่ายที่สุดโดยใช้ Arduino และ MIT app inventor

ทำไมฉันถึงสร้างสิ่งนี้

เมื่อเดือนที่แล้ว ลูกพี่ลูกน้องของฉันขอให้ฉันสร้างรถ ฉันจึงคิดอย่างหนักและสร้างสิ่งนี้ขึ้นมา

หมายเหตุ : สามารถสร้างได้ทั้งแบบมีและไม่มี adafruit motor shield V2 และแบบมีและไม่มีระบบยิง App สามารถแก้ไขได้ โดยบางวิธีในการแก้ไขจะแสดงอยู่ในบทช่วยสอนนี้

โปรดสมัครสมาชิก

ขั้นตอนการทำงาน:

  • App ส่ง string ไปยัง Bluetooth
  • Arduino ตรวจสอบ string
  • และทำงานตามคำสั่ง (เดินหน้า, ถอยหลัง ฯลฯ)

การเชื่อมต่อ:

เมื่อใช้ shield:

Servo 1 และ 2 ให้คงไว้ที่ตำแหน่งเริ่มต้น

Motor ควรอยู่ที่ M1 และ M4

HC-05 หรือ 06 RX และ TX ควรตรงกับบรรทัดที่ 2 :

SoftwareSerial mySerial(number of rxpinhere, numberoftxpinhere);

VCC และ GND ไปยัง 5V และ GND

เมื่อไม่ใช้ shield:

Servo 1 และ 2 :

  • VCC และ GND ไปยัง 5V และ GND ตามลำดับ
  • ขา orange สำหรับ Servo 1 ไปที่ 9 และ Servo 2 ไปที่ 10

Motor1 ควรอยู่ที่ 2, 3

Motor2 ควรอยู่ที่ 4, 5

HC-05 หรือ 06 RX และ TX ควรตรงกับบรรทัดที่ 2 :

  • SoftwareSerial mySerial(number of rxpinhere, numberoftxpinhere);
  • VCC และ GND ไปยัง 5V และ GND ตามลำดับ

โค้ด:

พร้อม shield:

หมายเหตุ: ในบรรทัดที่ 2 ตัวเลข 52 และ 53 จะต้องตรงกับการเชื่อมต่อ Bluetooth โดยลำดับการเชื่อมต่อคือ SoftwareSerial mySerial(RX, TX); :) Happy coding.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(52, 53); // RX and TX can be edited
String BT_input;
int LED = 13;
#include <Servo.h>
Servo s;
Servo s2;
#include <AFMotor.h>
AF_DCMotor motor(1);
AF_DCMotor motor1(4);
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
s.attach(10);
s2.attach(9);
s2.write(0);
s.write(0);
pinMode(LED, OUTPUT);
motor.setSpeed(255);
motor1.setSpeed(255);
motor.run(RELEASE);
motor1.run(RELEASE);
}
void loop() {
if (mySerial.available())
{
BT_input = mySerial.read();
Serial.println(BT_input);
if (BT_input=="1")
{
front();
}
if (BT_input=="3")
{
back();
}
if (BT_input=="2")
{
right();
}
if (BT_input=="4")
{
left();
}
if (BT_input=="5")
{
stop();
}
if (BT_input=="6")
{
shoot();
}
if (BT_input=="7")
{
shoot2();
}
}
}
void front(){
motor.run(FORWARD);
motor1.run(FORWARD);
}
void back(){
motor.run(BACKWARD);
motor1.run(BACKWARD);
}
void left(){
motor.run(BACKWARD);
motor1.run(FORWARD);
}
void right(){
motor.run(FORWARD);
motor1.run(BACKWARD);
}
void stop(){
motor.run(RELEASE);
motor1.run(RELEASE);
}
void shoot(){
s.write(120);
delay(100);
s.write(0);
}
void shoot2(){
s2.write(120);
delay(100);
s2.write(0);
}

ไม่มี shield

หมายเหตุ: ในบรรทัดที่ 2 ตัวเลข 52 และ 53 จะต้องตรงกับการเชื่อมต่อ Bluetooth โดยลำดับการเชื่อมต่อคือ SoftwareSerial mySerial(RX, TX); :) Happy coding.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(52, 53); // RX and TX can be edited
String BT_input;
int LED = 13;
#include <Servo.h>
Servo s;
Servo s2;
const int Motor_L_F = 2;
const int Motor_L_B = 3;
const int Motor_R_F = 4;
const int Motor_R_B = 5;
void setup() {

}
void loop() {
if (mySerial.available())
{
BT_input = mySerial.read();
Serial.println(BT_input);
if (BT_input=="1")
{
front();
}
if (BT_input=="3")
{
back();
}
if (BT_input=="2")
{
right();
}
if (BT_input=="4")
{
left();
}
if (BT_input=="5")
{
stop();
}
if (BT_input=="6")
{
shoot();
}
if (BT_input=="7")
{
shoot2();
}

ข้อมูล Frontmatter ดั้งเดิม

title: "Easiest Bluetooth car using Arduino and MIT app inventor"
description: "Control bluetooth car using arduino and HC-05 or 06 and MIT app inventor. Better to use with LEGO."
author: "syeddaanish2000"
category: ""
tags:
  - "hc-05"
  - "app inventor"
  - "easy"
  - "bluetooth"
  - "mit"
  - "arduino"
  - "smart appliances"
  - "app"
  - "hc06"
  - "hc-06"
  - "cars"
  - "robo"
  - "remote control"
  - "hc05"
  - "robots"
views: 8509
likes: 2
price: 1499
difficulty: "Easy"
components:
  - "1x Arduino Nano R3"
  - "1x l293 motor shield"
  - "2x DC Motor, 12 V"
  - "1x cardboard"
  - "4x Jumper wires (generic)"
  - "2x shooter"
  - "1x HC-05 Bluetooth Module"
  - "2x SG90 Micro-servo motor"
  - "1x Arduino UNO"
  - "1x Arduino Mega 2560"
tools: []
apps:
  - "1x my app"
  - "1x MIT App Inventor 2"
downloadableFiles:
  - "https://github.com/Toprun123/Arduino_car"
  - "https://github.com/Toprun123/Arduino_car"
documentationLinks: []
passwordHash: "5d4a4c6cc0e1cc6c1b1989813e101934adb578d416bd93f8b10a6f8d5d66b869"
encryptedPayload: "U2FsdGVkX188ehIvPCPOdP6o20mlNu/fw265/KoL/lmRw7nSHmBvBFjQ2K8k612MNrgIrM5P6eaVnxMMCbisBGOZAab7IWqJpXey7oZkZND6bNb3fMgoM5icWBUB9rbd"
seoDescription: "Build an easy Bluetooth car using Arduino, HC-05, and MIT app inventor. Perfect project for beginners using LEGO parts."
videoLinks:
  - "https://www.youtube.com/embed/XuExWv60OH4"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/easiest-bluetooth-car-using-arduino-and-mit-app-inventor-4e5622_cover.jpg"
lang: "th"