Cov txheej txheem:

Digitize Nkauj Nrog Arduino: 6 Kauj Ruam
Digitize Nkauj Nrog Arduino: 6 Kauj Ruam

Video: Digitize Nkauj Nrog Arduino: 6 Kauj Ruam

Video: Digitize Nkauj Nrog Arduino: 6 Kauj Ruam
Video: Tou Ly Vangkhue Yuav Pib Qhov Twg 1983 Digitized Complete Album 2024, Hlis ntuj nqeg
Anonim
Digitize Nkauj Nrog Arduino
Digitize Nkauj Nrog Arduino

Kuv xav tsim txoj haujlwm uas ua ke ob qho kuv nyiam tshaj plaws: kev tshawb fawb thiab suab paj nruag. Kuv xav txog txhua txoj hauv kev uas kuv tuaj yeem ua ke ob lub npe no, thiab, Kuv xav tias nws yuav txaus siab los ua Arduino ua si Fur Elise thaum nthuav tawm lub suab ntawm daim ntawv hauv Hertz. Tam sim no, cia peb pib tsim!

Koj yuav xav tau ib qho Arduino Uno lossis Mega, ntau jumper cables, Piezo buzzer, lub khob cij, 16*2 LCD npo nrog txhua tus wiper pins nyob rau hauv qhov chaw, thiab 10k Potentiometer (koj kuj tseem tuaj yeem hnov lawv raug hu ua potmeters)). Nws yog qhov zoo tshaj kom tau tag nrho cov khoom siv no ua ke ua ntej peb pib tsim.

Kauj Ruam 1: Hloov Cov Suab Paj Nruag Rau Hauv Cov Cim: Ncua Sijhawm Muaj Nqis

Hloov Cov Qub Suab Nkauj Rau Hauv Cov Lus Cim: Ncua Sijhawm Muaj Nqes
Hloov Cov Qub Suab Nkauj Rau Hauv Cov Lus Cim: Ncua Sijhawm Muaj Nqes

Muaj ob theem los digitally sau cov ntawv los ntawm cov qhab nia rau hauv nws qhov sib npaug digital. Ua ntej tshaj, peb yuav tsum tau sau lub sijhawm sau ntawv nyob hauv milliseconds. Kuv ua haujlwm daim ntawv pom hauv online rau txoj haujlwm no. Raws li seb puas yog ib daim ntawv sau tseg ib nrab ntawv, ib lub hlis twg, ntawv thib yim, thiab lwm yam, Kuv tau sau cov ntawv ntev mus rau milliseconds. Koj tuaj yeem pom cov lej no hauv kuv tus lej raws li ncua (); muaj nuj nqi thiab tus lej hauv cov ntawv yuav yog tus nqi qeeb hauv milliseconds peb tau txiav txim siab hauv theem no.

Kauj Ruam 2: Hloov Cov Suab Paj Nruag Rau Hauv Cov Cim: Hertz Qhov Tseem Ceeb

Hloov Cov Qub Suab Nkauj Rau Hauv Cov Cim: Hertz Qhov Tseem Ceeb
Hloov Cov Qub Suab Nkauj Rau Hauv Cov Cim: Hertz Qhov Tseem Ceeb

Ua ntej pib cov kauj ruam no, cia kuv txhais qee cov ntsiab lus kev paub. "Tus nqi" ntawm daim ntawv tuaj yeem siv sib pauv nrog cov lus "suab", "tus nqi", thiab "nco". Tam sim no, koj yuav tsum nyeem txhua daim ntawv ntawm zaj nkauj los ntawm tus qhab nia. Koj yuav tsum tau tom qab txhais txhua daim ntawv rau hauv Hertz siv lub suab paj nruag rau Hertz rooj, uas koj tuaj yeem pom yooj yim online. Ib yam uas yuav tsum nco ntsoov yog nruab nrab C tau teev tseg ua C4 ntawm lub rooj, thiab octave siab dua yog C5, thiab ntxiv rau. Thaum cov ntawv no tau sau tag nrho rau hauv Hertz, koj yuav muab qhov tseem ceeb tso rau hauv lub suab ua haujlwm (x, y, z); qhov twg X yog tus lej tus lej lossis tus lej int, ib txoj hauv kev ntawm kev hloov pauv uas kuv yuav piav qhia tom qab. Y yuav yog tus nqi Hertz uas koj nyuam qhuav sau, thiab Z yuav yog lub sijhawm sau tseg hauv milliseconds puag ncig mus rau ib puas feem pua. Kev ncua (); qhov tseem ceeb yuav yog lub sijhawm sau tseg. Tam sim no, cia tsim lub Circuit Court uas tuaj yeem ua suab paj nruag.

Kauj Ruam 3: Tsim Circuit Court

Tsim Circuit Court
Tsim Circuit Court

Tam sim no uas peb tau txhais tag nrho cov ntawv sau rau hauv cov txiaj ntsig digital uas lub khoos phis tawj tuaj yeem nkag siab, nws yog lub sijhawm los tsim lub Circuit Court. Pib los ntawm kev noj lub khob cij thiab tso lub vijtsam LCD nrog tus lej thawj (GND) hauv kab 14. Tso lub buzzer nyob txhua qhov chaw uas koj nyiam, thiab tso lub hwj chim ntsuas hluav taws xob nyob ib sab. Lub hom phiaj yog ua kab txhua yam, kom txo qis qhov tsis sib xws ntawm cov xov hlau. Muab Arduino nyob ib sab rau ntawm lub khob cij, thiab txuas 5v tus pin rau txoj kev tsheb nqaj hlau zoo, thiab tus pin hauv av mus rau txoj kev tsis zoo. Tam sim no, peb tau npaj los txuas cov dhia ntawm Arduino thiab cov khoom siv.

Tam sim no, tham txog cov koob ntawm LCD, thiab yuav xaim lawv li cas.

GND sawv rau hauv av, qhov no yog xaim tsis zoo nyob rau tam sim no. Hlau GND mus rau txoj kev tsis zoo ntawm lub khob cij.

VCC sawv cev rau Voltage ntawm Common Collector, thiab qhov no yog qhov uas koj txuas koj li 5-volt fais fab qhov chaw (txoj kev tsheb nqaj hlau zoo).

VO sawv rau qhov sib piv, xaim qhov no mus rau tus pin nruab nrab ntawm lub hwj chim. Txuas tus pin sab laug ntawm lub zog ntsuas hluav taws xob mus rau txoj kev tsheb nqaj hlau zoo, thiab tus pin sab xis rau hauv av tsheb nqaj hlau.

RS sawv rau Sau Npe Xaiv, thiab qhov no yog siv los ntawm Arduino los qhia cov zaub nyob qhov twg khaws cov ntaub ntawv. Txuas tus pin no rau tus pin 12 ntawm Arduino.

RW sawv rau Nyeem/Sau tus pin, uas Arduino siv los tshuaj xyuas yog tias lub vijtsam qhia qhov koj tau ua haujlwm rau nws los qhia. Txuas tus pin no mus rau txoj kev tsis zoo ntawm lub khob cij.

E sawv rau Enable, uas qhia LCD uas cov pixels kom qhib (tig rau) lossis xiam (tua). Txuas tus pin no rau Arduino tus pin 11.

D4, D5, D6, thiab D7 yog Display pins uas tswj cov cim thiab cov tsiaj ntawv raug nthuav tawm. Txuas lawv rau Arduino pins 5, 4, 3, thiab 2, feem.

Pin A, qee zaum sau tias LED, yog LED anode rau lub teeb pom kev zoo. Txuas qhov no mus rau txoj kab hluav taws xob zoo nrog xaim lossis nrog 220-ohm resistor. Cov tshuaj tiv thaiv zoo dua rau siv ntev dua vim nws tsis siv lub LCD, tab sis yog tias lub cuab yeej tsis siv nruab hnub thiab hmo ntuj, koj tsis xav tau tus tiv thaiv.

Pin K, qee zaum kuj (tsis meej pem) sau npe LED, yog tus pin hauv av LED. Txuas qhov no mus rau txoj kev tsheb ciav hlau hauv av.

Kauj Ruam 4: Kev Tshaj Tawm Txoj Cai: Yuav Ua Li Cas

Txuas koj Arduino rau hauv koj lub computer USB. Tshaj tawm cov cai hauv qab no siv Arduino IDE programmer.

#suav nrog

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd (rs, en, d4, d5, d6, d7);

void teeb tsa () {

// teeb tsa LCD tus lej ntawm kab thiab kab: lcd.begin (16, 2); // Luam tawm cov lus rau LCD. lcd.print ("Hertz Suab:"); ncua (1000); lub voj void () {// ua si e4 ncua (600); // ncua rau 0.6 vib nas this suab (10, 329.63, 300); // ua si e rau lub buzzer ntawm tus pin 10, kawg rau.3 secs lcd.print (" 329.63 "); // tso saib cov lus ntawm LCD" 329.63"

ncua (350); // ncua rau.35 vib nas this

lcd.clear (); // ntshiab LCD thiab rov pib dua rau cov lus tom ntej // ua si d4# suab (10, 311.13, 300); lcd.print ("311.13"); ncua (350); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (350); lcd.clear (); // play d4# tone (10, 311.13, 300); lcd.print ("311.13"); ncua (350); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (350); lcd.clear (); // ua si suab paj nruag b3 (10, 246.94, 300); lcd.print ("246.94"); ncua (400); lcd.clear (); // ua si suab d4 (10, 293.66, 300); lcd.print ("293.66"); ncua (400); lcd.clear (); // ua si suab c4 (10, 261.63, 300); lcd.print ("261.63"); ncua (400); lcd.clear (); // ua si a3 suab (10, 220, 900); lcd.print ("220.0"); ncua (1000); lcd.clear (); // line60 // helpave // avrdude.failure.eeprom // play d3 tone (10, 146.83, 300); lcd.print ("146.63"); ncua (350); lcd.clear (); // ua si suab f3 (10, 174.61, 300); lcd.print ("174.61"); ncua (400); lcd.clear (); // ua si a3 suab (10, 220, 300); lcd.print ("220"); ncua (400); lcd.clear (); // ua si suab paj nruag b3 (10, 246.94, 900); lcd.print ("246.94"); ncua (1000); lcd.clear ();

// ua si e3

suab nrov (10, 164.81, 300); lcd.print ("164.81"); ncua (400); lcd.clear (); // play g3# tone (10, 207.65, 300); lcd.print ("207.65"); ncua (400); lcd.clear (); // ua si b3 suab (10, 246.94, 300); lcd.print ("246.94"); ncua (400); lcd.clear (); // ua si suab c4 (10, 261.63, 900); lcd.print ("261.63"); ncua (1000); lcd.clear (); // play e tone (10, 164.81, 300); lcd.print ("164.81"); ncua (400); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (400); lcd.clear (); // play d4# tone (10, 311.13, 300); lcd.print ("311.13"); ncua (400); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (400); lcd.clear (); // play d4# tone (10, 311.13, 300); lcd.print ("311.13"); ncua (400); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (400); lcd.clear (); // ua si suab paj nruag b3 (10, 246.94, 300); lcd.print ("246.94"); ncua (400); lcd.clear (); // ua si suab d4 (10, 293.66, 300); lcd.print ("293.66"); ncua (400); lcd.clear (); // ua si suab c4 (10, 261.63, 300); lcd.print ("261.63"); ncua (400); lcd.clear (); // ua si a3 suab (10, 220, 900); lcd.print ("220.0"); ncua (1000); lcd.clear (); // ua si suab d3 (10, 146.83, 300); lcd.print ("146.83"); ncua (400); lcd.clear (); // ua si suab f3 (10, 174.61, 300); // eeprom 20--6 yesno, flash 65--0 noyes lcd.print ("174.61"); ncua (400); lcd.clear (); // ua si a3 suab (10, 220, 300); lcd.print ("220.0"); ncua (400); lcd.clear (); // ua si suab paj nruag b3 (10, 246.94, 900); lcd.print ("246.94"); ncua (1000); lcd.clear (); // ua si suab f3 (10, 174.61, 300); lcd.print ("174.61"); ncua (400); lcd.clear (); // ua si suab c4 (10, 261.63, 300); lcd.print ("261.63"); ncua (400); lcd.clear (); // ua si b3 suab (10, 246.94, 300); lcd.print ("246.94"); ncua (400); lcd.clear (); // ua si a3 suab (10, 220, 900); lcd.print ("220.0"); ncua (1000); lcd.clear (); // ua si b3 suab (10, 246.94, 300); lcd.print ("246.94"); ncua (400); lcd.clear (); // ua si suab c4 (10, 261.63, 300); lcd.print ("261.63"); ncua (400); lcd.clear (); // ua si suab d4 (10, 293.66, 300); lcd.print ("293.66"); ncua (400); lcd.clear (); // ua si e4 suab (10, 329.63, 900); lcd.print ("329.63"); ncua (1000); lcd.clear (); // ua si suab g3 (10, 196, 300); lcd.print ("196.0"); ncua (400); lcd.clear (); // ua si suab f4 (10, 349.23, 300); lcd.print ("349.23"); ncua (400); lcd.clear (); // ua si e4 suab (10, 329.23, 300); lcd.print ("329.23"); ncua (400); lcd.clear (); // ua si suab d4 (10, 293.63, 900); lcd.print ("293.63"); ncua (1000); lcd.clear (); // ua si e3 suab (10, 164.81, 300); lcd.print ("164.81"); ncua (400); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (400); lcd.clear (); // ua si suab d4 (10, 293.63, 300); lcd.print ("293.63"); ncua (400); lcd.clear (); // ua si suab c4 (10, 261.63, 900); lcd.print ("261.63"); ncua (1000); lcd.clear (); // ua si suab d3 (10, 146.83, 300); lcd.print ("146.83"); ncua (400); lcd.clear (); // ua si suab d4 (10, 293.63, 300); lcd.print ("293.63"); ncua (400); lcd.clear (); // ua si suab c4 (10, 261.63, 300); lcd.print ("261.63"); ncua (400); lcd.clear (); // ua si suab paj nruag b3 (10, 246.94, 900); lcd.print ("246.94"); ncua (1000); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (400); lcd.clear (); // play d4# tone (10, 311.13, 300); lcd.print ("311.13"); ncua (350); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (350); lcd.clear (); // play d4# tone (10, 311.13, 300); lcd.print ("311.13"); ncua (350); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (350); lcd.clear (); // ua si b3 suab (10, 246.94, 300); lcd.print ("246.94"); ncua (400); lcd.clear (); // ua si suab d4 (10, 293.66, 300); lcd.print ("293.66"); ncua (400); lcd.clear (); // ua si suab c4 (10, 261.63, 300); lcd.print ("261.63"); ncua (400); lcd.clear (); // ua si a3 suab (10, 220, 900); lcd.print ("220.0"); ncua (1000); lcd.clear (); // ua si suab d3 (10, 146.83, 300); lcd.print ("146.83"); ncua (350); lcd.clear (); // ua si suab f3 (10, 174.61, 300); lcd.print ("174.61"); ncua (400); lcd.clear (); // ua si a3 suab (10, 220, 300); lcd.print ("220.0"); ncua (400); // ua si b3 lcd.clear (); suab nrov (10, 246.94, 900); lcd.print ("246.94"); ncua (1000); lcd.clear (); // ua si e3 suab (10, 164.81, 300); lcd.print ("164.81"); ncua (400); lcd.clear (); // ua si g#3 suab (10, 207.65, 300); lcd.print ("207.65"); ncua (400); lcd.clear (); // ua si b3 suab (10, 246.94, 300); lcd.print ("246.94"); ncua (400); lcd.clear (); // ua si suab c4 (10, 261.63, 900); lcd.print ("261.63"); ncua (1000); ncua (300); lcd.clear (); // ua si e3 suab (10, 164.81, 300); lcd.print ("164.81"); ncua (400); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (400); lcd.clear (); // play d4# tone (10, 311.13, 300); lcd.print ("311.13"); ncua (400); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (400); lcd.clear (); // play d4# tone (10, 311.13, 300); lcd.print ("311.13"); ncua (400); lcd.clear (); // ua si e4 suab (10, 329.63, 300); lcd.print ("329.63"); ncua (400); lcd.clear (); // ua si suab paj nruag b3 (10, 246.94, 300); lcd.print ("246.94"); ncua (400); lcd.clear (); // ua si suab d4 (10, 293.66, 300); lcd.print ("293.66"); ncua (400); lcd.clear (); // ua si suab c4 (10, 261.63, 300); lcd.print ("261.63"); ncua (400); lcd.clear (); // ua si a3 suab (10, 220, 900); lcd.print ("220.0"); ncua (1000); lcd.clear (); // ua si suab d3 (10, 146.83, 300); lcd.print ("146.83"); ncua (400); lcd.clear (); // ua si suab f3 (10, 174.61, 300); lcd.print ("174.61"); ncua (400); lcd.clear (); // ua si a3 suab (10, 220, 300); lcd.print ("220.0"); ncua (400); lcd.clear (); // ua si suab paj nruag b3 (10, 246.94, 900); lcd.print ("246.94"); ncua (1000); lcd.clear (); // ua si suab f3 (10, 174.61, 300); lcd.print ("174.61"); ncua (400); lcd.clear (); // ua si suab c4 (10, 261.63, 300); lcd.print ("261.63"); ncua (400); lcd.clear (); // ua si suab paj nruag b3 (10, 246.94, 300); lcd.print ("246.94"); ncua (400); lcd.clear (); // ua si a3 suab (10, 220, 900); lcd.print ("220.0"); ncua (1000); lcd.clear (); }

Kauj Ruam 5: Kev Tso Cai Code: Txhua Yam Yog Qhov Twg?

Cia peb txhais qee qhov haujlwm hauv Askiv, yog li koj tuaj yeem nkag siab cov cai.

suab (x, y, z); = ua si suab nrog lub suab ntawm y Hertz, rau lub suab nrov ntawm tus pin x, rau z milliseconds.

lcd.print ("XYZ"); = luam cov lus nrog cov cim XYZ rau LCD npo. (piv txwv li tso saib Hertz suab)

ncua (x); = ncua rau x milliseconds.

const int X = Y = teeb tsa qhov sib txawv tsis tu ncua X rau tus pin Y, thiab siv X lossis Y los ua haujlwm rau lub cuab yeej.

lcd.clear (); = tshem lub vijtsam LCD thiab rov pib dua rau lub vijtsam tshiab

pinMode (X, NTAWV); = teeb tus pin X rau hom tso zis

Thaum koj nkag siab tag nrho cov haujlwm no, koj tuaj yeem hloov pauv qhov hloov pauv tau yooj yim nrog cov ntaub ntawv uas koj sau thaum txhais cov nkauj, thiab tom qab ntawd koj tuaj yeem sau koj tus kheej nkauj!

Kauj Ruam 6: Tiav lawm !

Tiav lawm !!!
Tiav lawm !!!
Tiav lawm !!!
Tiav lawm !!!

Koj ib txwm muaj Arduino uas ua yeeb yaj kiab Fur Elise thiab nthuav qhia qhov cim tseg hauv Hertz, lossis koj tau ua Arduino uas ua suab paj nruag ntawm zaj nkauj uas koj tau xaiv, thiab qhia cov ntawv uas koj xav qhia. Ua tsaug rau koj mus ntsib qhov kev qhia no, thiab kuv vam tias koj txoj haujlwm no ntawm Arduino.

Pom zoo: