Cov txheej txheem:

Arduino Morse Code Writer: 7 Kauj Ruam (nrog Duab)
Arduino Morse Code Writer: 7 Kauj Ruam (nrog Duab)

Video: Arduino Morse Code Writer: 7 Kauj Ruam (nrog Duab)

Video: Arduino Morse Code Writer: 7 Kauj Ruam (nrog Duab)
Video: Arduino and Morse code 2024, Kaum ib hlis
Anonim
Image
Image
Arduino Morse Code Writer
Arduino Morse Code Writer

Kuv tau tsim tus neeg hlau uas tuaj yeem hloov cov ntawv muab rau hauv Morse code thiab tom qab ntawv sau nws !! Nws tau ua los ntawm cov duab los qhia thiab Lego thiab rau cov khoom siv hluav taws xob Kuv siv Arduino thiab tsuas yog ob lub cav.

Khoom siv

Arduino Uno board Stepper lub cev muaj zog Micro servo SG90ULN2003 stepper lub cev muaj zog tsav module Lub zog mov module Breadboard4 × Jumper xov hlau 6 × Poj niam-rau-txiv neej dupont xov hlau 9V1A AdapterUSB cable Cardboard 2 × Ntoo dowels 2 × Springs Straw White paperLegoSuper kua nplaum Kub nplaum phom Elastic band (los ua tus cwj mem tuav) Txiab Txiab

Kauj Ruam 1: Tsim Lub Hauv Paus

Tsim Lub Hauv Paus
Tsim Lub Hauv Paus
Tsim Lub Hauv Paus
Tsim Lub Hauv Paus
Tsim Lub Hauv Paus
Tsim Lub Hauv Paus

Pib los ntawm kev tsim lub hauv paus. Mine yog 4 qhov dav thiab 20 qhov ntev ntev, tom qab tsim ib txheej nrog cov qhov ntev no, Kuv tau tsim ib lub pob zeb dav dav nyob ib puag ncig nws tawm ntawm qhov sib txawv ntawm ib sab kom tawm qhov chaw rau lub stepper lub cev muaj zog, tom qab ntawd kuv ntxiv pobzeb daim mus rau ib nrab qhov uas yuav muaj daim kab xev. Siv Lego ua rau nws ruaj khov thiab hloov pauv tau yooj yim. Txhawm rau ua daim ntawv yob, Kuv txiav ib daim ntawv A4 ntawv 1.2cm dav (Kuv xaiv qhov dav vim tias nws zoo ib yam li Lego log kuv siv, koj tuaj yeem ua rau koj loj dua lossis me dua nyob ntawm koj lub log) thiab kuv glued lawv qhov kawg ua ke los tsim ib txoj hlua ntev heev, tom qab ntawd kuv qhwv nws ncig lub log.

Kauj ruam 2: Servo Piece

Qhov Servo Piece
Qhov Servo Piece
Qhov Servo Piece
Qhov Servo Piece
Qhov Servo Piece
Qhov Servo Piece

Rau cov kauj ruam no koj xav tau:

  • ob tug ntoo dowels 4cm ntev
  • ob lub qhov dej ntev 2cm
  • ib lub straw txiav rau ob daim 2cm ntev txhua
  • ib qho 12cm los ntawm 4cm daim duab los qhia ntawv
  • ob 4cm los ntawm 1.5cm daim ntawv los xij
  • ib qho 4cm los ntawm 2cm daim duab los qhia ntawv

Ua ntej, muab cov kua nplaum tso rau ntawm ib qho ntawm 4 txog 1.5 daim, tom qab ntawd ntxig cov springs thiab cov quav hauv lub dowels, tom qab ntawd lo lwm daim ntawv los ntawm lwm daim los tuav txhua yam hauv qhov chaw.

Qhov thib ob, lo rau 4cm los ntawm 2cm daim rau saum cov hlua.

Qhov thib peb, ntxeev tag nrho daim thiab lo ib lub me me rau sab nraub qaum ntawm nws, tsis yog hauv nruab nrab tab sis me ntsis mus rau sab laug. (Kuv tsis nco qab ntxiv lub dowel me me hauv thawj daim duab)

Thaum kawg, txiav lub qhov hauv daim loj ntawm daim duab los qhia qhov loj ntawm lub hauv ntej ntawm lub cav servo thiab lo lub cav rau hauv, tom qab ntawd lo rau daim uas peb nyuam qhuav ua nrog lub dowels mus rau daim loj kom thaum lub servo txav, nws thawb me me dowel qis uas tig thawb cov dej ntws los ib yam.

Kuv tau txiav txiav txog 3cm los ntawm qhov hauv qab ntawm 12cm los ntawm 4cm thooj thiab txuas ob qho ntxiv 4cm los ntawm 1.5cm daim rau nws, tom qab ntawd npog nrog 5.5cm los ntawm 4cm daim ntawv duab los qhia thiab tuav tus cim Kuv tau ua me me voj ntawm cov hlua khi thiab kaw nws rau ib daim me me ntawm cov duab los qhia tom qab ntawd kuv glued uas mus rau 4cm los ntawm 2cm thooj uas yuav txav mus thaum lub servo pib. Cov kev ntxiv no tau nres tus cim ntawm kev txav ntawm ib sab mus rau ib sab thaum cov dej ntws rov qab los.

Kauj Ruam 3: Ntxiv Servo Motor thiab Ntawv Roll rau Lub Hauv Paus

Ntxiv rau Servo Motor thiab Ntawv Roll rau hauv paus
Ntxiv rau Servo Motor thiab Ntawv Roll rau hauv paus
Ntxiv rau Servo Motor thiab Ntawv Roll rau hauv paus
Ntxiv rau Servo Motor thiab Ntawv Roll rau hauv paus

Kuv ntxiv ob lub cib ntxiv rau ib sab ntawm lub hauv paus los txhawb nqa qhov khoom siv thiab kuv tau muab nws tso rau hauv qhov chaw. Tom qab ntawd kuv ntxiv lub log mus rau qhov kawg ntawm lub hauv paus.

Kauj Ruam 4: Tsim Lub Stepper Motor Frame

Tsim lub Stepper Motor Frame
Tsim lub Stepper Motor Frame
Tsim lub Stepper Motor Frame
Tsim lub Stepper Motor Frame
Tsim lub Stepper Motor Frame
Tsim lub Stepper Motor Frame

Cov kauj ruam no yog qhov nyuaj me ntsis, vim tias lub cev tsis tau ua kom haum nrog Lego zoo kawg nkaus. Txawm li cas los xij, Kuv tau tswj kom ua nws los ntawm kev siv ob lub qhov hauv lub cav kom ruaj ntseg nws nyob hauv qhov chaw. Tom ntej no, Kuv glued lub log Lego rau lub ntsis ntawm lub cav thiab tom qab ntawd kuv muab tso rau sab xis ntawm lub hauv paus ntawm ib sab uas kuv sab laug qhib hauv qib 1.

Kauj Ruam 5: Tiav Touches

Tiav Touches
Tiav Touches
Tiav Touches
Tiav Touches
Tiav Touches
Tiav Touches
Tiav Touches
Tiav Touches

Kuv ntxiv ob daim hlau los npog lub log kom kho cov ntawv hauv qhov chaw. Thiab kuv ntxiv ob daim hlau me me ib qho los tuav cov xov hlau ntawm lub tshuab tsav thiab lwm qhov los tuav daim ntawv. Thaum kawg, Kuv tau hloov lub stepper lub cev muaj zog log mus rau qhov loj me me uas txav cov ntawv zoo dua li lub log qub.

Kauj Ruam 6: Cov Khoom Siv Hluav Taws Xob

Electronics
Electronics
Electronics
Electronics

Thaum kawg, koj yuav tsum txuas lub cav mus rau Arduino thiab xa cov cai.

Peb yuav pib nrog lub tshuab servo, txuas cov xim av xim av (xaim av) rau GND tus pin, tom qab ntawd xaim liab (xaim hluav taws xob) mus rau 5V tus pin, thiab xaim txiv kab ntxwv (lub teeb liab xaim) mus rau Dig #5 tus pin Tom ntej no, lub tshuab hluav taws xob txuas, txuas 1N1 rau khawb #11, 1N2 rau khawb #10, 1N3 rau khawb #9, 1N4 rau khawb #8, 5V mus rau qhov zoo ntawm lub khob cij thiab hauv av pin rau qhov tsis zoo ntawm daim ntawv qhia zaub mov Thiab tsis txhob hnov qab txuas cov khoom siv hluav taws xob rau lub khob cij ua kom ntseeg tau tias nws qhov zoo thiab qhov tsis zoo sib dhos ua kom raug rau ob sab sib luag ntawm lub khob cij. Yog tias koj hnov qab ua li ntawd, koj yuav thim rov qab lub zog rau koj txoj haujlwm, thiab koj tsis xav ua qhov ntawd.

Txog cov cai, kuv tau sau plaub txoj hauv kev, ib qho los sau tus lej, ib qho los sau tus cim, thiab ob qho kom tso qhov chaw nruab nrab ntawm txhua tsab ntawv thiab txhua lo lus. Txoj kev ntawd, Kuv tsuas tuaj yeem hu cov txheej txheem no thaum kuv xav tau lawv es tsis txhob sau nws ntxiv rau txhua tsab ntawv. Tom qab ntawd kuv tau sau lub voj uas hla txhua tsab ntawv ntawm kab ntawv thiab sau nws, Sab hauv nws, Kuv tau sau ib nqe lus yog tias txhua tsab ntawv tab sis koj tuaj yeem sau nws hauv kab lus hloov yog tias koj xav tau. Tau kawg koj tuaj yeem ntxiv rau cov cai kom pab tau txoj haujlwm nyeem cov lej. Thaum txhua qhov thaiv tau npaj tiav, tsuas yog theej thiab muab cov lej tso rau hauv koj li IDE. Tsis txhob hnov qab teeb tsa lub stepper, servo, thiab cov ntawv qiv. Tom qab ntawd, koj zoo mus.

Nws ua haujlwm li cas

Thaum Arduino pib qhov kev zov me nyuam saib thawj daim ntawv ntawm cov ntawv., Thiab nyob ntawm seb nws yog leej twg, nws hu cov haujlwm uas sau nws hauv Morse code. Piv txwv li, thaum lub teev teev npe hu ua, lub cav servo tau teeb tsa rau 160 uas txav tus cwj mem los, tom qab ntawd nws tau teeb tsa rov qab mus rau 90 uas cia cov dej ntws rov qab los txav tus cwj mem nrog lawv. Thiab yog tias lub luag haujlwm ua haujlwm raug hu, tus servo txav tus cwj mem los, tom qab ntawd lub tshuab hluav taws xob tig lub log uas rub daim ntawv ua tus cwj mem sau tus cim. Thiab yog tias ib qho ntawm cov haujlwm hauv qhov chaw hu ua stepper motor tig tab sis nrog tus cwj mem nce kom nws rub daim ntawv ua qhov chaw nruab nrab ntawm cov ntawv lossis cov lus. Thaum nws ua tiav, nws mus rau tsab ntawv tom ntej thiab rov ua cov txheej txheem qub. Kuv vam tias koj nyiam nws;)

Cov cai

#suav nrog

#include #include #include const int stepsPerRevolution = 150; // Qhov no yog qhov sib txawv rau stepper motor String kab lus = "*nyob zoo"; // Hloov qhov kev hloov pauv no los sau cov lus sib txawv tab sis tsuas yog sau ntawv me me thiab pib koj lo lus nrog "*" Stepper myStepper (stepsPerRevolution, 8, 10, 9, 11); Servo myServo; // Nov yog txoj hauv kev uas ua rau tus neeg hlau sau tus lej tsis muaj qhov khoob () {Serial.println ("pib pib"); myServo.write (160); ncua (1000); myServo.write (90); ncua (1000); myStepper.step (stepsPerRevolution); ncua (1000); Serial.println ("teev ua tiav"); } // Nov yog txoj hauv kev uas ua rau tus neeg hlau sau cov ntawv tsis muaj qhov khoob () {Serial.println ("dash pib"); myServo.write (160); ncua (1000); myStepper.step (stepsPerRevolution); ncua (1000); myServo.write (90); ncua (1000); myStepper.step (stepsPerRevolution); ncua (1000); Serial.println ("khiav ua tiav"); } // Nov yog txoj hauv kev uas ua rau cov neeg hlau tso ib qho chaw nruab nrab ntawm txhua tsab ntawv tsis muaj chaw nyob () {Serial.println ("pib qhov chaw"); myServo.write (90); ncua (1000); myStepper.step (200); ncua (1000); Serial.println ("qhov chaw ua tiav"); } // Nov yog txoj hauv kev uas ua rau cov neeg hlau tawm qhov chaw loj dua ntawm txhua lo lus tsis muaj dabtsis bigSpace () {myServo.write (90); myStepper.step (250); ncua (1000); } tsis muaj teeb tsa teeb tsa () {// muab koj cov cai teeb tsa ntawm no, kom khiav ib zaug: Serial.begin (9600); myStepper.setSpeed (100); myServo.attach (5); int thawj = kab lus.indexOf ('*'); // qhov no rau lub voj hla dhau txhua tsab ntawv ntawm txoj hlua thiab tom qab ntawv hu txoj hauv kev zoo los sau nws rau (int i = 0; kuv <kab lus.length (); i ++) {yog (kab lus.charAt (thawj+kuv) == 'a') {Serial.print (".-"); teev (); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'b') {Serial.print ("-…"); khiav (); teev (); teev (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'c') {Serial.print ("-.-."); khiav (); teev (); khiav (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'd') {Serial.print ("-.."); khiav (); teev (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'e') {Serial.print ("."); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'f') {Serial.print ("..-."); teev (); teev (); khiav (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'g') {Serial.print ("-."); khiav (); khiav (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'h') {Serial.print ("…."); teev (); teev (); teev (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'kuv') {Serial.print (".."); teev (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'j') {Serial.print (".---"); teev (); khiav (); khiav (); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'k') {Serial.print ("-.-"); khiav (); teev (); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'l') {Serial.print (".-.."); teev (); khiav (); teev (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'm') {Serial.print ("-"); khiav (); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'n') {Serial.print ("-."); khiav (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'o') {Serial.print ("---"); khiav (); khiav (); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'p') {Serial.print (".--."); teev (); khiav (); khiav (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'q') {Serial.print ("--.-"); khiav (); khiav (); teev (); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'r') {Serial.print (".-."); teev (); khiav (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 's') {Serial.print ("…"); teev (); teev (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 't') {Serial.print ("-"); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'u') {Serial.print ("..-"); teev (); teev (); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'v') {Serial.print ("…-"); teev (); teev (); teev (); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'w') {Serial.print (".--"); teev (); khiav (); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'x') {Serial.print ("-..-"); khiav (); teev (); teev (); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'y') {Serial.print ("-.--"); khiav (); teev (); khiav (); khiav (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == 'z') {Serial.print ("-.."); khiav (); khiav (); teev (); teev (); qhov chaw (); } lwm yog (kab lus.charAt (thawj + kuv) == '') {Serial.print ("/"); bigSpace (); }}} void loop () {// Tsis txhob sau dab tsi ntawm no}

Kauj ruam 7: Troubleshooting

Lub log tsis txav mus

Tej zaum yuav muaj kev sib txhuam ntau dhau ntawm lub log thiab daim ntawv, sim ua kom lub log me ntsis lossis hloov nws.

Lub log rub daim ntawv tab sis tom qab ntawd nws tig mus yam tsis rub daim ntawv

Nco ntsoov tias koj tau kaw lub log nyob hauv nruab nrab ntawm lub cav tsav tsheb

Cov dots thiab cov kab sib txuas tau txuas nrog

Txheeb xyuas yog tias lub teev, qhov khiav thiab qhov chaw ua haujlwm raug sau kom raug, lawv yuav tsum zoo li no:

// Nov yog txoj hauv kev uas ua rau tus neeg hlau sau dotvoid dot () {Serial.println ("pib dot"); myServo.write (160); ncua (1000); myServo.write (90); ncua (1000); myStepper.step (stepsPerRevolution); ncua (1000); Serial.println ("teev ua tiav"); }

// Nov yog txoj hauv kev uas ua rau tus neeg hlau sau lub cim

void dash () {Serial.println ("dash pib"); myServo.write (160); ncua (1000); myStepper.step (stepsPerRevolution); ncua (1000); myServo.write (90); ncua (1000); myStepper.step (stepsPerRevolution); ncua (1000); Serial.println ("ua kom tiav"); }

// Nov yog txoj hauv kev uas ua rau tus neeg hlau tso qhov chaw nruab nrab ntawm txhua tsab ntawv

tsis muaj chaw seem () {Serial.println ("pib qhov chaw"); myServo.write (90); ncua (1000); myStepper.step (200); ncua (1000); Serial.println ("qhov chaw ua tiav"); }

Pom zoo: