Cov txheej txheem:

Tswj Arduino Nrog Android thiab USB: 5 Kauj Ruam
Tswj Arduino Nrog Android thiab USB: 5 Kauj Ruam

Video: Tswj Arduino Nrog Android thiab USB: 5 Kauj Ruam

Video: Tswj Arduino Nrog Android thiab USB: 5 Kauj Ruam
Video: Making a &#!$%ing Button 2024, Kaum ib hlis
Anonim
Image
Image
Yam Koj Xav Tau
Yam Koj Xav Tau

Cov lus qhia no tsuas yog ua kom pom sai ntawm "Arduino USB Serial Extension" uas tau tsim los ntawm Thunkable tus tsim tawm, Pavitra. Nws tseem tab tom txhim kho yog li xav txog qhov no yog hom beta version.

Hauv qhov yooj yim, tam sim no koj tuaj yeem tsim kev cai Android app thiab siv nws los sib txuas lus ntawm USB nrog ntau pawg Arduino sib txawv.

Kuv tau npaj qhov ua piv txwv yooj yim qhov twg lub app tuaj yeem hloov RGB LED ntawm 5 lub xeev sib txawv (Liab, Ntsuab, Xiav, Dawb thiab Tawm) tab sis kuv txaus siab tiag tiag pom cov tswv yim twg hauv zej zog Cov Lus Qhia los nrog.

Kauj Ruam 1: Yam Koj Xav Tau

Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau

Yam yuavtsum tau kawm uantej

  1. Qee qhov kev paub pib ntawm block-based programming, xws li Kos lossis App Inventor
  2. Kev nkag siab yooj yim ntawm Arduino - piv txwv li koj tau ua tiav qhov "Blink" kos duab

Kho vajtse

  1. Ib Arduino + USB Cable. Kuv tau sim qhov no nrog Uno, Leonardo thiab Micro.
  2. Ib Android Xov Tooj
  3. USB OTG txuas
  4. Qee qhov khoom siv hluav taws xob rau kev sim

Software

  1. Arduino IDE
  2. Ib qho "App Inventor 2" software sib xws, Kuv tau xaiv rau Thunkable
  3. Ib daim qauv ntawm Pavitra's Arduino USB Serial Extension

Kauj Ruam 2: Tsim Koj Li Circuit Court

Tsim Koj Li Circuit Court
Tsim Koj Li Circuit Court
Tsim Koj Li Circuit Court
Tsim Koj Li Circuit Court

Koj tuaj yeem yooj yim tawm nrog tsuas yog Arduino nws tus kheej ntawm no thiab siv on-board LED, tab sis kom ua rau nws ntxim siab me ntsis Kuv tau siv RGB LED.

Lub Circuit Court yog qhov yooj yim heev:

Cov pin hauv av ntawm LED txuas nrog ib qho ntawm Arduino cov av hauv av [Cov Hlau Dub], Cov liab, ntsuab thiab xiav txuas nrog PWM pins ntawm Ω resistors. Koj tuaj yeem lees paub PWM pins los ntawm ~ cim ib sab ntawm tus lej tus lej.

Cov xov hlau liab, ntsuab thiab xiav nyob hauv daim duab muaj qhov yooj yim los qhia qhov twg ntawm ceg ntawm LED sib raug rau cov xim twg. Hauv qee qhov LEDs tus pin xiav thiab ntsuab yuav thim rov qab.

Kauj Ruam 3: Sau Koj Li Code

Txhua tus lej hauv qab no tuaj yeem pom ntawm Github

Pib los ntawm teeb tsa qee cov npe sib txawv rau koj Arduino Pins

// kuj txawv txav rau Serial input

int tswv yim = 0; // Pins rau LEDs const int LED = 13; const int redPin = 11; const int greenPin = 9; const int bluePin = 10;

Tom ntej no, ntxiv qhov no rau teeb tsa () muaj nuj nqi:

void teeb tsa () {

// Pib qhov saib xyuas ntawm 9600 baud Serial.begin (9600); // Tshaj tawm cov LEDs los ua tus pinMode (LED, OUTPUT); pinMode (redPin, OUTPUT); tus pinMode (greenPin, OUTPUT); tus pinMode (bluePin, OUTPUT); }

Tom qab ntawd kos rau Serial input:

void voj () {

// txheeb xyuas yog tias muaj cov ntaub ntawv nkag, yog (Serial.available ()> 0) {// yog li, ces nyeem cov ntaub ntawv nkag. cov tswv yim = Serial.read (); // ua xim sib txawv nyob ntawm tus nqi nkag yog (input == '1') {make_colour (255, 0, 0); } lwm yog (input == '2') {make_colour (0, 255, 0); } lwm yog (input == '3') {make_colour (0, 0, 255); } lwm yog (input == '4') {make_colour (0, 0, 0); } lwm yog (input == '5') {make_colour (255, 255, 255); }}}

Thaum kawg, ua kom cov xim tsim nyog:

void make_colour (int r, int g, int b) {

// tsuas yog rau kev sim Serial.println ("Ua Xim"); // teeb tsa lub luag haujlwm rau txhua tus pin analogWrite (redPin, r); analogWrite (greenPin, g); analogWrite (bluePin, b); }

Kauj ruam 4: Tsim Koj Lub App

Tsim Koj Lub App
Tsim Koj Lub App
Tsim Koj Lub App
Tsim Koj Lub App
Tsim Koj Lub App
Tsim Koj Lub App

Txhawm rau pib nrog app sai li sai tau koj tuaj yeem clone nws ncaj qha rau Thunkable los ntawm txhaj rau ntawm no.

Tsim

Tus tsim ntawm no app yog txhob txwm yooj yim. Nws tsuas yog ob peb lub khawm thiab, tau kawg, Arduino cov ntawv txuas ntxiv.

Yog tias koj tsis paub nrog txhim kho.aix cov ntaub ntawv koj tuaj yeem nyeem Conor phau ntawv qhia pib sai ntawm no.

Code

Hauv cov thaiv, kuv tau tsim cov txheej txheem hu ua lighsOn uas yog hu ua txhua lub sijhawm nias lub pob.

Cov nyees khawm liab, ntsuab thiab xiav xa cov cim '1', '2' thiab '3' mus rau Arduino, feem.

Cov cim '4' thiab '5' tau siv los tig lub LED dawb thiab tawm.

Nws kuj yog lub tswv yim zoo kom suav nrog khawm rov pib dua uas kaw thiab rov qhib kev sib txuas rau Arduino

Kauj Ruam 5: Sim Nws

Sim Nws Tawm
Sim Nws Tawm
Sim Nws Tawm
Sim Nws Tawm

Tam sim no koj tau npaj los sim nws.

1. Rub cov duab kos rau koj Arduino

2. Nruab.apk ntawm koj Lub Xov Tooj

3. Txuas koj lub xov tooj rau koj Arduino nrog OTG Cable thiab koj zoo mus.

Teeb meem

Thaum koj xub pib lub app nrog Arduino txuas nrog, koj yuav tsum tau tso cai rau nws nkag mus rau lub cuab yeej USB (Arduino)

Yog tias koj pom lub sijhawm ua yuam kev, sim kaw qhov kev sib txuas thiab tom qab ntawd qhib nws dua. Qhov no yuav tsum txhim kho koj cov teeb meem, tab sis nco ntsoov tias qhov no tseem tab tom sim yog li thov tawm lus yog tias nws tsis ua haujlwm rau koj.

Pom zoo: