Cov txheej txheem:

Tsis Siv Neeg Xov Tooj Charger: 6 Kauj Ruam (nrog Duab)
Tsis Siv Neeg Xov Tooj Charger: 6 Kauj Ruam (nrog Duab)

Video: Tsis Siv Neeg Xov Tooj Charger: 6 Kauj Ruam (nrog Duab)

Video: Tsis Siv Neeg Xov Tooj Charger: 6 Kauj Ruam (nrog Duab)
Video: Lub Zog Nruab Nrog (Hmong Dubbed) 2024, Hlis ntuj nqeg
Anonim
Tsis Siv Neeg Xov Tooj Charger
Tsis Siv Neeg Xov Tooj Charger

"Cov lus qhia no tau tsim los ua kom tau raws txoj haujlwm xav tau ntawm Makecourse ntawm University of South Florida (www.makecourse.com)"

Lub tswv yim tom qab txoj haujlwm no yog tsim cov cuab yeej uas tuaj yeem them lub xov tooj, thiab tom qab ntawd tshem nws thaum lub xov tooj mus txog 100%. Qhov no yuav nres teeb meem ntawm kev them nyiaj ntau dua.

Kauj Ruam 1: Cov Khoom Yas

Cov Khoom Siv Yas
Cov Khoom Siv Yas
Cov Khoom Siv Yas
Cov Khoom Siv Yas
Cov Khoom Siv Yas
Cov Khoom Siv Yas
Cov Khoom Siv Yas
Cov Khoom Siv Yas

Muaj qee qhov khoom siv uas tau siv 3D luam tawm. Cov khoom siv no suav nrog lub hauv paus, tus tuav rau lub charger, khib thiab pinion iav teeb (ib qho iav ib txwm thiab kab tawm uas hloov pauv mus rau kev txav mus los), thiab lub hauv paus rau txhua yam kom ua haujlwm. Cov khoom no yuav piav qhia hauv kab lus hauv qab no. Raws li qhov tshwm sim

Charger Holder

Lub hom phiaj ntawm qhov no yog tuav lub xov tooj them nyiaj, lossis tsawg kawg muab nws zoo dua thiab qib hauv paus kom ua raws.

Hauv paus

Lub hauv paus muaj lub nplhaib rau tus tuav lub xov tooj nrog rau kev taug qab rau lub iav teeb.

Tus Xov Tooj

Tuav lub xov tooj, pom tseeb

Xov tooj Caj Npab

Tsiv thiab tuav lub xov tooj

Khib thiab Pinion Iav Teeb

Siv txav lub xov tooj them rov qab los

Kauj Ruam 2: Txheeb Tawm Cov Khoom Uas Tsis Luam 3D

Cov no yog cov khoom uas tau yuav los rau qhov haujlwm lossis twb muaj lawm. Rau qee qhov ntu kuv txuas rau lawv/cov khoom zoo sib xws ntawm amazon, tab sis xav tias dawb kom tau txais lawv nyob txhua qhov chaw.

Micro Servo: https://www.amazon.com/J-Deal-Micro- Helicopter-Air …

Txuj 0-180 Servo: https://www.amazon.com/Futaba-FUTM0031-S3003-Stand …

HC-05 Bluetooth Serial Module:

Xov tooj thiab Xov Tooj Charger

Arduino

Cov qhob cij

Lub thawv lossis lub thoob rau lub hauv paus

Kov Sensor:

Kauj ruam 3: Electronics

Electronics
Electronics

Lub Circuit Court rau txoj haujlwm no yuav xav tau qee qhov, feem ntau vim yog HC-05 module. Ntau ntawm cov qauv ntawm hom no yog tus nqi kwv yees li 3.3V txog 6V, uas yog nrog rau kev ua haujlwm ntawm Arduino. Tab sis, rau kev sib txuas lus txuas tus lej Rx qee zaum ua haujlwm tau zoo dua nrog tsuas yog 3.3V. Raws li pom hauv daim duab saum toj no ob lub servos tau txuas rau Vin tus pin ntawm Arduino. Qhov hluav taws xob ntxiv no tuaj yeem muab los ntawm txhua yam, Kuv siv lub roj teeb 9 volt. Qhov ntsuas qhov ntsuas tau txuas rau hauv 5V ntawm Arduino. Qhov no yog vim tias tag nrho cov khoom muaj teeb meem khiav tawm ntawm tib qhov hluav taws xob. Qhov ntsuas qhov ntsuas tau txuas rau tus pin 2 yog li nws tuaj yeem siv ua tus pin cuam tshuam. Tom qab ntawd bluetooth module txuas nrog Rx thiab Tx pins rau kev sib txuas lus txuas. Nruab nrab ntawm Rx tus pin ntawm tus qauv thiab Tx ntawm Arduino yog 2 kilo ohm resistor nrog 1 kilo ohm txuas rau hauv av. Qhov no pab tswj hwm qhov hluav taws xob nkag mus.

Kauj ruam 4: Sib dhos

Los ua ke
Los ua ke

Kev sib dhos yog yooj yim heev.

  1. nrog qee cov kua nplaum super mount koj cov servos hauv lawv txoj haujlwm, ib qho rau cov iav los ntawm kev txiav tawm ntawm lub hauv paus thiab ib qho nyob ze qhov twg ntawm lub hauv paus ntawm lub xov tooj.
  2. Txuas tus kov sensor rau tus tuav lub xov tooj, yog li nws tuaj yeem paub thaum lub xov tooj nyob ntawd.
  3. Tom qab ntawd txuas lub iav thiab caj npab rau lawv cov kev pabcuam
  4. Xyuas kom cov xov hlau tsis cuam tshuam nrog lwm cov khoom thaum koj sau koj cov khoom siv hluav taws xob

Kauj ruam 5: Code

Muaj peb txheej txheej uas yuav nthuav tawm, ib qho lej rau Arduino, uas tau tsim hauv Arduino IDE thiab ob tus lej uas tau ua hauv Android Studio. Android apps zoo ib yam tsuas yog ib qho yog tag nrho app uas taug qab lub roj teeb lub neej thiab ib qho tsis ua. Qhov thib ob yog rau lub hom phiaj sim.

Arduino Txoj Cai

Lub ntsiab lus tseem ceeb ntawm txoj cai no yog txhawm rau ua haujlwm kov lub tshuab thiab lub cav, nws tau txais cov lus txib los ntawm lub xov tooj thiab ua raws nws.

#suav nrog // hu rau lub tsev qiv ntawv servo yog li peb tuaj yeem tswj ob lub servosServo servo1; Servo servo2; // tsim ob qhov khoom siv servo rau txhua qhov servo motor int a = 0; // nrhiav qhov sib txawv rau kev sim int q = 0; // qhov sib txawv uas tso cai rau yuav tsum tau ncua ua ntej rau pluggin txheej txheem pib char c; // sib txawv uas muaj cov ntawv xov xwm los ntawm lub xov tooj tsis muaj dab tsi teeb tsa () {attachInterrupt (digitalPinToInterrupt (2), AH, FALLING); // txuas qhov cuam tshuam cuam tshuam kom paub meej thaum lub ntsuas pom pom thaum lub xov tooj tawm ntawm servo1.attach (10); servo2.attach (9); // initializes ob servos Serial.begin (9600); // pib kev sib txuas lus txuas ntawm tus nqi zoo ib yam li ntawm bluetooth module servo2.write (20); // pib teeb tsa servos rau pib txoj haujlwm servo1.write (180); }

void voj () {

yog (Serial.available ()) {// qhov kev txheeb xyuas no yog tias muaj dab tsi los ntawm hauv xov tooj hla tus lej txuas Tx thiab Rx c = Serial.read (); // nyeem dab tsi los ntawm yog (c == 't') {// yog tias lub tshuab ntaus ntawv nyeem thaum ntawd txhais tau tias lub xov tooj tau them tag nrho, cov txheej txheem tshem tawm pib servo2.write (120); // tshem tawm lub charger ncua (5000); // tos kom paub tseeb muaj sijhawm rau kev tshem tawm servo1.write (110); // txav lub xov tooj mus rau qhov chaw ncaj kom teeb liab //Serial.println("here "); attachInterrupt (digitalPinToInterrupt (2), AH, FALLING); // rov txuas qhov cuam tshuam}} yog (q == 1) {// yog tias qhov xwm txheej rau pluggin nyob rau hauv yog ture ces pib nrog txuas lub charger ncua (10000); servo2.write (0); // txav servo mus rau txoj haujlwm q = 0; // rov kho qhov xwm txheej}}

tsis muaj dabtsis AH () {

//Serial.println("in "); servo1.write (180); // poob lub xov tooj platform rau hauv txoj haujlwm them nyiaj q = 1; // pib qhov kev pom zoo los txuas ntxiv cov txheej txheem // a = 1; detachInterrupt (digitalPinToInterrupt (2)); // tshem tawm qhov cuam tshuam, yog li yuav tsis muaj teeb meem nrog kev cuam tshuam pib thaum nws yuav tsis}

Hauv App

Ntawm no kuv tsuas yog tso saib daim ntawv thov raug tab sis cov ntawv xeem cov ntawv kuj tseem yuav muab, qhov sib txawv tsuas yog kev tshem tawm ntawm kev ua haujlwm thiab tau txais qib roj teeb. Cov lej cim tau hais yog ib qho uas yog tus qauv rau cov xov tooj txuas rau cov khoom siv xws li cov qauv.

pob com.example.daniel.make; ntshuam android.bluetooth. BluetoothAdapter; ntshuam android.bluetooth. BluetoothDevice; ntshuam android.bluetooth. BluetoothSocket; ntshuam android.os. Handler; ntshuam android.support.v7.app. AppCompatActivity; ntshuam android.os. Bundle; ntshuam android.content. Intent; ntshuam android.content. IntentFilter; ntshuam android.os. BatteryManager; ntshuam java.io. IOException; ntshuam java.io. OutputStream; ntshuam java.util. Set; ntshuam java.util. UUID;

pej xeem chav MainActivity txuas ntxiv AppCompatActivity {

// tsim cov khoom tsim nyog Handler handler; // pab nrog lub voj Runnable runnable; // khiav tsis tu ncua BluetoothAdapter mBluetoothAdapter; BluetoothSocket mmSocket; BluetoothDevice mmDevice; OutputStream mmOutputStream; volatile boolean stopWorker; ntiag tug OutputStream outputStream; ntiag tug txoj hlua DEVICE_NAME = "HC-05"; ntiag tug kawg UUID PORT_UUID = UUID.fromString ("00001101-0000-1000-8000-00805f9b34fb"); ntiag tug BluetoothAdapter ntaus ntawv; ntiag tug BluetoothSocket qhov (socket); @Override tiv thaiv void onCreate (Bundle savedInstanceState) {// yog cov lus qhia uas khiav thaum lub app tau tsim super.onCreate (savedInstanceState); // displya tsim setContentView (R.layout.activity_main); runnable = tshiab Runnable () {@Override pej xeem tsis muaj dab tsi khiav () {// khiav ntau zaus hauv qib = (int) getBattery (); // tau txais qib roj teeb tam sim no yog (qib == 100) {// yog qib roj teeb mus txog 100% sim {getBT (); // txuas rau lub bluetooth module openBT (); // qhib nws sendData (); // xa cov ntaub ntawv tsim nyog kaw BT (); // kaw qhov khoom} ntes (IOException ex) { }} handler.postDelayed (runnable, 5000); // ncua sijhawm}}; tus tuav = tus tuav tes tshiab (); handler.postDelayed (runnable, 0); }

pej xeem ntab getBattery () {

Intent batteryIntent = registerReceiver (null, IntentFilter tshiab (Intent. ACTION_BATTERY_CHANGED)); // tsim qhov kev txiav txim uas txuas rau lub roj teeb int qib = batteryIntent.getIntExtra (BatteryManager. EXTRA_LEVEL, -1); // tau txais qib zoo dua int scale = batteryIntent.getIntExtra (BatteryManager. EXTRA_SCALE, -1); // tau txais cov nplai ntawm lub roj teeb yog tias (qib == -1 || teev == -1) {// thaum ua yuam kev rov qab 50.0f; } ntab batt = (qib/(ntab) nplai)*100.0f; // tau txais qhov ntsuas kom rov zoo sib ntaus; // rov qab qib}

tsis muaj dab tsi getBT () {// tau txais kev sib txuas ntawm bluetooth tau

mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter (); // tau txais lub adapter yog (! mBluetoothAdapter.isEnabled ()) {// ua kom ntseeg tau tias lub xov tooj ahs xiav hniav ntawm Intent enableBluetooth = New Intent (BluetoothAdapter. ACTION_REQUEST_ENABLE); // thov kom nws tig rau yog tias tsis pibActivityForResult (enableBluetooth, 0); } Teeb pairedDevices = mBluetoothAdapter.getBondedDevices (); // tau txais cov npe ntawm kev sib txuas bluetooth yog (pairedDevices.size ()> 0) {// xyuas kom muaj qee yam khoom siv rau (BluetoothDevice device: pairedDevices) {// loops los ntawm cov cuab yeej yog (device.getName (). sib npaug ("HC-05")) {// txheeb xyuas yog tias nws yog ib qho mmDevice = ntaus ntawv; // txuag nws tawg; }}}}

void openBT () cuam tshuam IOException {

UUID uuid = UUID.fromString ("00001101-0000-1000-8000-00805f9b34fb"); // Standard // SerialPortService ID mmSocket = mmDevice.createRfcommSocketToServiceRecord (uuid); // txuas rau lub cuab yeej nrog tus lej ID mmSocket.connect (); // txuas mmOutputStream = mmSocket.getOutputStream (); // pib lub peev xwm xa cov ntaub ntawv rau arduino module}

void sendData () cuam tshuam IOException {// chav kawm uas xa t mus rau arduino

mmOutputStream.write ('t'); }

void closeBT () cuam tshuam IOException {// kaw txhua qhov kev sib txuas mus rau arduino

stopWorker = muaj tseeb; mmOutputStream.close (); mmSocket.close (); }}

Kauj ruam 6: Cov ntaub ntawv

Ua tsaug rau kev nyeem ntawv, txuas nrog yog cov ntaub ntawv uas tau siv hauv txoj haujlwm no

Pom zoo: