Cov txheej txheem:

Arduino Morse Code Transmitter: 11 Kauj Ruam
Arduino Morse Code Transmitter: 11 Kauj Ruam

Video: Arduino Morse Code Transmitter: 11 Kauj Ruam

Video: Arduino Morse Code Transmitter: 11 Kauj Ruam
Video: Morse Code Converter with arduino 2024, Hlis ntuj nqeg
Anonim
Arduino Morse Code Transmitter
Arduino Morse Code Transmitter
Arduino Morse Code Transmitter
Arduino Morse Code Transmitter

Hauv cov lus qhia no, koj yuav siv Arduino Uno los tsim Morse Code tus xa xov, thiab siv lub ntsuas saib xyuas los nyeem cov lus koj tau kis.

Qhov koj yuav xav tau:

Arduino Ib

Cov qhob cij

Buzzer

Nyees khawm

Jumper xov hlau

Kauj Ruam 1: Muab Lub Hwj Chim Rau Koj Daim Npav Breadboard

Muab Lub Hwj Chim rau Koj Daim Npav Breadboard
Muab Lub Hwj Chim rau Koj Daim Npav Breadboard

Txuas lub jumper hlau los ntawm 5V tus pin ntawm koj Arduino Uno rau kab zoo ntawm koj lub khob cij.

Kauj Ruam 2: Ua Kom Koj Lub Breadboard

Av Koj Breadboard
Av Koj Breadboard

Tam sim no txuas cov xaim los ntawm ib qho ntawm GND pins ntawm Arduino mus rau kab tsis zoo ntawm koj lub khob cij.

Kauj Ruam 3: Ntxig Koj Lub Pob

Ntxig Koj Khawm
Ntxig Koj Khawm

Ntxig koj lub pob. Nco ntsoov tias ob ntawm nws ob txhais ceg nyob ntawm txhua sab ntawm cov channel nqes nruab nrab ntawm koj lub khob cij, thiab ob txhais ceg tau tso khov kho. Nws yog ib qho yooj yim kom khoov lawv thaum koj nias nyuaj, yog li saib xyuas thaum koj thawb lub pob.

Kauj Ruam 4: Av Koj Lub Pob

Av Koj Khawm
Av Koj Khawm

Txuas lub pob mus rau hauv av los ntawm kev tso ib qho kawg rau hauv kab ib yam li cov ceg saum toj ntawm koj lub pob, thiab lwm qhov kawg rau hauv kab tsis zoo uas koj yav dhau los txuas rau hauv av.

Kauj Ruam 5: Txuas Koj Lub Pob

Txuas Koj Khawm
Txuas Koj Khawm

Kaw lub khawm khawm thiab tso cai rau Arduino nyeem nws cov lus nkag los ntawm kev txuas ib lub xov hlau los ntawm kab ib yam li hauv qab khawm khawm, thiab tus lej 7 ntawm Arduino.

Kauj Ruam 6: Ntxig Koj Buzzer

Ntxig koj Buzzer
Ntxig koj Buzzer

Ntxig koj lub suab nrov kom lub cim "+" nyob rau sab saum toj, lossis txhais ceg ntev me ntsis, nyob ntawm ib sab ntawm lub khob cij raws li koj lub xaim txuas rau 5V.

Kauj Ruam 7: Qhib Buzzer

Hauv av Buzzer
Hauv av Buzzer

Txuas lub pob rau hauv av nrog xaim los ntawm tib kab raws li nws luv luv ceg mus rau txoj kab tsis zoo ntawm lub khob cij uas koj tau txuas yav dhau los rau GND.

Kauj Ruam 8: Fais Fab Buzzer

Fais fab Buzzer
Fais fab Buzzer

Muab lub zog rau lub suab nrov thiab tso cai rau Arduino los tswj nws nrog xaim los ntawm kab ib yam li nws cov ceg ntev dua rau tus pin 8 ntawm Arduino.

Kauj Ruam 9: Sau Koj Li Cai

Sau Koj Txoj Cai
Sau Koj Txoj Cai

Luam thiab paste peb cov cai, lossis rub tawm cov ntawv txuas.

Zoo li txoj hlua Morse = {".-", "-…", "-.-.", "-..", ".", "..-", "-.", "…. ",".. ",".--- "," -.- ",".-.. ","-","-. "," --- ",".--. ", "--.-", ".-.", "…", "-", "..-", "…-", ".--", "-..-", "-.--" ","-.. "," E "};

Cov tsiaj ntawv zoo li qub = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', ' x ',' y ', 'z', 'E'}; unsigned ntev push_length, start_push, end_push; // lub sij hawm uas khawm twg yog nias int khawm = 7; // input pin rau laub khawm int buzzer = 8; // outpu tus pin rau LED hlua txoj cai = ""; // txoj hlua uas ib tus tsiaj ntawv khaws cia

void teeb tsa () {

Serial.begin (9600); pinMode (khawm, INPUT_PULLUP); // sab hauv pullup resistor tau siv los ua kom yooj yim ntawm Circuit pinMode (buzzer, OUTPUT); Serial.println ("Pib koj cov lus!"); }

void lub voj ()

{MorseTransmission: thaum (digitalRead (khawm) == HIGH) {} start_push = millis (); // sijhawm ntawm lub pob nyem xov tooj cua (buzzer, 150); thaum (digitalRead (khawm) == LOW) {} end_push = millis (); // sijhawm ntawm khawm tso tawm noTone (buzzer); push_length = end_push - pib_push; // lub sij hawm rau lub khawm twg yog nias yog (push_length> 50) {// rau tus account rau hloov debouncing code += dot_or_dash (push_length); // muaj nuj nqi los nyeem dot lossis dash} thaum ((millis () - end_push) <500) // yog lub sijhawm nruab nrab ntawm lub pob nyem ntau dua 0.5sec, hla lub voj thiab mus rau cov ntawv tom ntej {yog (digitalRead (khawm) == LOW) {tau txais MorseTransmission; }} Morse_translation (chaws); // muaj nuj nqi rau decipher code rau hauv niam ntawv}

char dot_or_dash (ntab ntev)

{yog (ntev 50) {rov qab '.'; // yog tias khawm nias tsawg dua 0.6sec, nws yog tus dot} ntxiv yog (ntev> 600) {rov qab '-'; // yog tias khawm nias ntau dua 0.6sec, nws yog qhov nrawm}}

tsis muaj dab tsi Morse_translation (String morsecode)

{int kuv = 0; yog (code == ".-.-.-") {Serial.print ("."); // rau kev tawg} lwm qhov {thaum (Morse ! = "E") // lub voj rau kev sib piv cov lej nkag nrog cov tsiaj ntawv array {yog (Morse == morsecode) {Serial.print (Alphabet ); tawg; } kuv ++; } yog (Morse == "E") {Serial.println ("Yuam kev!"); // yog tias cov lej nkag tsis zoo ib yam ntawv, yuam kev}} code = ""; // rov pib dua txoj cai rau txoj hlua khoob}

Kauj Ruam 10: Siv Serial Monitor los Nyeem Koj Cov Lus

Siv Serial Monitor los nyeem koj cov txiaj ntsig!
Siv Serial Monitor los nyeem koj cov txiaj ntsig!

Qhib cov ntawv saib xyuas kom pom koj cov lus thaum koj nias lub pob kom tsim Morse Code. Siv cov lus qhia saum toj no los ua ntu zus koj cov ntawv teev thiab cov cim kom tsim nyog!

Kauj Ruam 11: Xav Tau Ntau Txoj Haujlwm Zoo Li No?

Xav Tau Ntau Txoj Haujlwm Zoo Li No?
Xav Tau Ntau Txoj Haujlwm Zoo Li No?

Tau txais ib feem rau 2-3 qhov haujlwm hauv ib hlis thiab cov lus qhia thiab yees duab los tsim lawv nrog MakeCrate!

Pom zoo: