Trung tâm đào tạo thiết kế vi mạch Semicon


  • ĐĂNG KÝ TÀI KHOẢN ĐỂ TRUY CẬP NHIỀU TÀI LIỆU HƠN!
  • Create an account
    *
    *
    *
    *
    *
    Fields marked with an asterisk (*) are required.
wafer.jpg

Hướng dẫn làm xe điều khiển từ xa bằng điện thoại bằng board Arduino

E-mail Print PDF

[​IMG]Chuẩn bị: 
1. Điện thoại smartphone android (có bluetooth).
2. Mạch Arduino Uno R3
3. Mạch Bluetooth HC-05
4. Mạch điều khiển motor L9110

5. Bó cáp đực cái
6. Chiếc xe điều khiển đồ chơi bị hư, nhưng phần cơ (motor và nhong) còn tốt.
7. Pin 6v – có thể mua pin 4 cục AA nối lại, nhưng mau hết lắm, nên mua 4 cục pin xạc loại AA có thể xạc lại nhiều lần. (100k / 1 cặp – 2 cục, mua 2 cặp 200k).
Mọi thứ bạn mua trên hshop có thể thanh toán sau khi nhận hàng tại nhà nên yên tâm. 
Cách làm: 

1. Cài IDE để nạp chương trình cho mạch Arduino tại địa chỉ:http://arduino.cc/en/Main/Software
2. Cắm mạch arduino vào máy tính và nạp vào đoạn mã sau:

Mã (c):
          
[HASHTAG]#include[/HASHTAG] <SoftwareSerial.h>          
[HASHTAG]#include[/HASHTAG] <Servo.h>          
int bluetoothTx = 2;          
int bluetoothRx = 3;          
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);          
// Motor 1 - control forward and fack          
int Motor1A = 5;          
int Motor1B = 6;          
//Motor 2 - control left and right          
int Motor2A = 9;          
int Motor2B = 10;          
void setup()          
{          
   //Setup Bluetooth serial connection to android          
   bluetooth.begin(115200);          
   bluetooth.print("$$$");          
   delay(100);          
   bluetooth.println("U,9600,N");          
   bluetooth.begin(9600);          
             
             
   pinMode( Motor1A, OUTPUT );          
   pinMode( Motor1B, OUTPUT );          
   digitalWrite( Motor1A, LOW );          
   digitalWrite( Motor1B, LOW );          
             
   pinMode( Motor2A, OUTPUT );          
   pinMode( Motor2B, OUTPUT );          
   digitalWrite( Motor2A, LOW );         
digitalWrite( Motor2B, LOW );          
}          
int flag1 = -1;          
int flag2 = -1;          
void loop()          
{          
   //Read from bluetooth and write to usb serial          
   if(bluetooth.available())          
   {          
     char toSend = (char)bluetooth.read();          
     if(toSend == 'S')          
     {          
         flag1 = 0;          
         flag2 = 0;          
         digitalWrite( Motor1A, LOW );          
         analogWrite( Motor1B, LOW );          
                   
         digitalWrite( Motor2A, LOW );          
         analogWrite( Motor2B, LOW );          
     }          
     if(toSend == 'F' || toSend == 'G' || toSend == 'I')          
     {          
         if(flag1 != 1)          
         {          
           flag1 = 1;          
           digitalWrite( Motor1A, HIGH );          
           analogWrite( Motor1B, 50 );          
         }          
     }          
     if(toSend == 'B' || toSend == 'H' || toSend == 'J')     
{          
         if(flag1 != 2)          
         {          
           flag1 = 2;          
           digitalWrite( Motor1B, HIGH );          
           analogWrite( Motor1A, 50 );          
         }          
     }          
     if(toSend == 'L' || toSend == 'G' || toSend == 'H')          
     {          
         if(flag2 != 1)          
         {          
           flag2 = 1;          
           digitalWrite( Motor2B, HIGH );          
           analogWrite( Motor2A, 50 );          
         }          
     }          
     else          
     if(toSend == 'R' || toSend == 'I' || toSend == 'J')          
     {          
         if(flag2 != 2)          
         {          
           flag2 = 2;          
           digitalWrite( Motor2A, HIGH );          
           analogWrite( Motor2B, 50 );          
         }          
     }          
     else          
     {          
if(flag2 != 3)          
         {          
           flag2 = 3;          
           digitalWrite( Motor2A, LOW );          
           analogWrite( Motor2B, LOW );          
         }          
     }          
   }          
}          
 
3. Ráp mọi linh kiện lại với nhau sơ đồ sau:
[​IMG]
Sản phẩm sau khi ráp. [​IMG]
[​IMG]
4. Cài ứng dụng “Car bluetooth RC” điều khiển xe lên smartphone.

[​IMG]
http://play.google.com/store/apps/details?id=com.buncaloc.carbluetoothrc
[​IMG]
Các bạn nhớ rate ứng dụng cho mình, đó sẽ là động lực cho những project kế tiếp.

 

 

NGUỒN: http://icdesignvn.com/

Bạn có đam mê ngành thiết kế vi mạch và bạn muốn có mức lương 1000 usd cùng lúc bạn

đang muốn tìm một Trung tâm để học vậy hãy đến với ngành vi mạch tại SEMICON

  HotLine: 0972 800 931 or 0938 838 404  Ms Duyên

 

 

Related Articles

Chat Zalo