Cov txheej txheem:

Daim iav Infinity Nrog LCD thiab IR Sensor: 5 Kauj Ruam
Daim iav Infinity Nrog LCD thiab IR Sensor: 5 Kauj Ruam

Video: Daim iav Infinity Nrog LCD thiab IR Sensor: 5 Kauj Ruam

Video: Daim iav Infinity Nrog LCD thiab IR Sensor: 5 Kauj Ruam
Video: Zam Txim Zam Nyog 3 Zaug - Tsua Muas Video 2024, Kaum ib hlis
Anonim
Daim iav Infinity Nrog LCD thiab IR Sensor
Daim iav Infinity Nrog LCD thiab IR Sensor
Daim iav Infinity Nrog LCD thiab IR Sensor
Daim iav Infinity Nrog LCD thiab IR Sensor
Daim iav Infinity Nrog LCD thiab IR Sensor
Daim iav Infinity Nrog LCD thiab IR Sensor

Txoj haujlwm no yuav qhia koj yuav ua li cas koj tuaj yeem ua Daim iav Infinity. Lub hauv paus ntsiab lus yog tias LEDs uas nyob ntawm daim iav tsim lub teeb uas tsoo los ntawm daim iav tom qab mus rau daim iav pem hauv ntej qhov twg qee lub teeb khiav tawm kom peb tuaj yeem pom sab hauv thiab qee qhov rov pom dua rau tom qab iav thiab tsim cov txiaj ntsig tsis muaj qhov kawg. Qhov no yog ua tawm ntawm Daim iav Infinity Nrog Ultra Sonic Sensors Qhia los ntawm Hack Sioux Falls thiab Yuav Ua Li Cas Txuas I2C Lcd Zaub rau Arduino Uno los ntawm JunezRiyaz.

Khoom siv

1. Lub thawv duab ntxoov ntxoo ($ 50)

2. 1-txoj kev Daim iav Zaj Duab Xis ($ 17)

3. Ib qho RGB LED teeb sawb ($ 30)

4. Arduino ($ 35)

5. Daim iav ($ 10)

Yeem:

1. IR Sensor thiab Chaw Taws Teeb ($ 20)

2. LCD ($ 20)

3. 7 Poj niam rau Txiv Neej Txuas

4. 3 Txiv neej rau Txiv Neej Txuas

Cov cuab yeej

1. Soldering Hlau

2. Hlau Cutter thiab Stripper

3. Ib yam dab tsi los txiav daim iav nrog

*Nco tseg txhua tus nqi hauv CAD thiab qhov ntau thiab tsawg yuav nyob ntawm lub thawv uas koj siv.

Kauj Ruam 1: Txhim Kho Daim iav thiab Daim iav Zaj Duab Xis

Txhim Kho Daim iav thiab Daim iav Zaj Duab Xis
Txhim Kho Daim iav thiab Daim iav Zaj Duab Xis
Txhim Kho Daim iav thiab Daim iav Zaj Duab Xis
Txhim Kho Daim iav thiab Daim iav Zaj Duab Xis

Thawj qhov ua yog txhawm rau txhim kho daim iav uas yuav nyob tom qab ntawm lub thawv duab ntxoov ntxoo. Koj xav tau ib qho uas yog qhov loj me lossis tau txais ib qho uas loj dua thiab tom qab ntawd txiav nws. Tab sis rau qhov no, koj yuav tsum siv daim iav thiab tsis yog zaj duab xis vim tias peb xav kom txhua lub teeb pom kev rov qab, daim iav zaj duab xis kuj tuaj yeem siv tus qauv ntawm cov khoom nws nyob yog tias nws tsis yog iav.

Thaum koj tab tom txhim kho daim iav kom ntseeg tau nws nyob hauv lub thawv duab ntxoov ntxoo, Kuv xav kom siv cov ntoo me me thiab cov ntsia hlau kom ntseeg tau tias daim iav tsis txav mus. Kuv tsis muaj daim iav nyob rau lub sijhawm kuv yuav tsum ua tiav txoj haujlwm no yog li kuv siv zaj duab xis (Koj tuaj yeem pom hauv cov duab). Lub tswv yim ua haujlwm tab sis tsis zoo heev thiab muab lub ntsej muag thiab tsis zoo uas hauv kuv lub tswv yim tsis zoo.

Txhua daim iav zaj duab xis yuav txawv me ntsis tab sis qhov uas kuv tau hais kom ntxuav lub iav uas peb tau muab zaj duab xis tso rau tom qab ntawd siv daim kab xev txhawm rau tshem tawm zaj duab xis tiv thaiv uas nyob ntawm ib sab thiab siv dej xab npum hauv tshuaj tsuag. lub raj mis muab zaj duab xis tso rau ntawm iav. Tom qab ntawd siv daim npav rho nyiaj lossis daim txhuam cev txhawm rau tshem tawm cov pa cua thiab dej ntau dhau. Kuv ib zaug ntxiv tsis muaj iav tab sis nws tseem ua haujlwm zoo ib yam. Tom qab ntawd tso lub iav kom qhuav ib hmo thiab nws yuav tsum ua tiav.

Kauj Ruam 2: Teeb Teeb LED Sawb

Teeb tsa LED Sawb
Teeb tsa LED Sawb
Teeb tsa LED Sawb
Teeb tsa LED Sawb

Txog cov LEDs kuv tsuas yog siv cov kab xev ob sab los lo rau ntawm tus ncej thiab ua lub qhov rau xaim kom tawm los. Ntawm txhua lub ces kaum, Kuv tau siv cov khoom coj los txuas rau lwm lub pluaj kom lub npov zoo li tsis muaj cov npoo sib npaug. Nco ntsoov tsuas yog txiav ib daim kab xev ntawm cov ntsiab lus uas muaj kev sib cuag uas yuav tso cai rau qhov ntawd tshwm sim thiab tsis hloov qhov kev coj ua LEDs txuas rau ib leeg lub npe hu ua thim rov qab polarity. Cov kab ntawv uas kuv tau txais muaj cov xub kom paub tseeb tias qhov no tsis tshwm sim yog li nco ntsoov xyuas lawv txhua tus taw tes rau tib txoj kev.

Kuv tau ua lub qhov me me tso lub cable hla mus rau sab nraum lub thawv, cov LEDs uas kuv muaj yog 3 Tus lej nyob hauv LEDs yog li kuv muaj lub zog, hauv av thiab cov ntaub ntawv txuas. Kuv siv Digital Pin 3 rau cov ntaub ntawv txuas, nco ntsoov ntsuas koj cov hlua LED kom paub tseeb tias lawv ua haujlwm ua ntej lo lawv rau ntawm tus ncej thiab nco ntsoov siv tsuas yog qhov ntsuas pom zoo rau kuv ib qho uas yog 5 - 6 V.

Kauj Ruam 3: Mount IR Sensor thiab LCD (Yeem Tau)

Mounting IR Sensor thiab LCD (Yeem Xaiv)
Mounting IR Sensor thiab LCD (Yeem Xaiv)
Mounting IR Sensor thiab LCD (Yeem Xaiv)
Mounting IR Sensor thiab LCD (Yeem Xaiv)
Mounting IR Sensor thiab LCD (Yeem Xaiv)
Mounting IR Sensor thiab LCD (Yeem Xaiv)

Kuv tau xaiv los siv IR sensor thiab thaj chaw deb los hloov cov teeb pom kev zoo thiab siv thiab LCD los qhia tus neeg siv cov kev xaiv uas lawv muaj rau qhov cuam tshuam.

Txhawm rau txhawm rau LCD thiab IR lub ntsej muag Kuv yuav siv rab phom kub kub thiab lo lawv rau saum tus ncej thiab txuas txhua yam rau tom qab tab sis kuv tsis xav kom lawv kho vim tias kuv yuav tau tshem lawv tom qab qhov project ua tiav

Txhawm rau txuas cov LCD thiab IR Txais Kuv tau siv Txiv neej rau Poj Niam Txuas uas txuas rau hauv Arduino rau cov ntaub ntawv nrog rau hauv av thiab lub zog. Txhawm rau xaim txhua yam Kuv tau siv tus pin 12 nrog 2 kΩ resistor ntawm cov ntaub ntawv tus pin rau IR sensor, Pin Pin A4 rau SDA ntawm LCD adn Analog Pin 5 rau SCL ntawm LCD.

Kauj ruam 4: Code

Txog qhov haujlwm no, Kuv siv kuv ob peb lub tsev qiv ntawv uas koj yuav tsum rub tawm los siv. Kuv yuav muab lawv tso rau ntawm no, nco ntsoov tias kuv nyob ntawm windows yog li ntawd yuav muaj kev cuam tshuam yog tias koj nyob ntawm Mac lossis Linux.

Koj yuav tsum tau hloov tus lej pixels nyob ntawm tus lej LEDs koj muaj. Kuv kuj tau tsim hauv Serial Monitor interface yog li koj tuaj yeem cuam tshuam nrog txoj kev ntawd nrog nws yog tias koj tsis siv IR sensor.

// Cov tsev qiv ntawv

#include Adafruit_NeoPixel.h> #include #include #include // Pins thiab Qhov tseem ceeb // Pins thiab qhov tseem ceeb txuas rau RECV_PIN = 12; IRrecv irrecv (RECV_PIN); decode_results cov txiaj ntsig; unsigned ntev key_value = 0; const int NUMPIXELS = 27;

Adafruit_NeoPixel pixels = Adafruit_NeoPixel (NUMPIXELS, 3);

LiquidCrystal_I2C lcd (0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Variables int IRNumb; ua IRNumb2; int zaj sawv = 0; uint32_t rainbowColor = pixels. Color (0, 0, 0); char cov ntaub ntawv = 0; char input2 = 0; tus r; tus g; tus b; int breakCondition = 0; tsis muaj teeb tsa teeb tsa () {// Pib lub ntsiab lus uas tsis tas yuav tsum tau rov ua dua. lcd.begin (16, 2); // Txheeb xyuas 16 kab thiab 2 kab ntawm lcd zaub lcd.backlight (); // Txhawm rau qhib lub teeb pom kev zoo Serial.begin (9600); pixels.begin (); irrecv.enableIRIn (); Serial.println ("Sau 0 los tua lub teeb"); // Pib Cov Lus Qhia Serial.println ("Nkag mus rau 1 tig lub LEDs kom dawb"); Serial.println ("Nkag mus rau 2 kom muaj lub voj voog LEDs los ntawm cov xim sib txawv"); Serial.println ("Nkag mus rau 3 txhawm rau kho cov xim LED ntawm tus kheej"); } tsis muaj dab tsi voj () {IRNumb = 10; IRScan (); mainOptions (); yog (Serial.available ()> 0) {// Txheeb xyuas yog tias muaj tus cim? cov tswv yim = (char) Serial.read (); } // Xaiv cov kev xaiv sib txawv yog (input == '1' || IRNumb == 1) {rainbowColor = colourChange (255, 255, 255); // Dawb setAll (rainbowColor); // Hloov kho LEDs} ntxiv yog (input == '0' || IRNumb == 0) {rainbowColor = colourChange (0, 0, 0); // Tawm setAll (rainbowColor); // Hloov kho cov LEDs ntxiv yog tias (cov tswv yim == '2' || IRNumb == 2) {breakCondition = 0; r = 0 hli; g yog 0;. b = 0;

Serial.println ("Nkag mus rau txhua yam uas tsis yog 2 kom tawm qhov kev ua no, tom qab ntawd ib qho ntawm cov kev xaiv ua ntej rau cov txiaj ntsig tshiab.");

lcd.clear (); // Ntxuav qhov screen lcd.setCursor (0, 0); lcd.print ("Tawm siv ib qho twg"); lcd.setCursor (0, 1); lcd.print ("loog ntawd! = 2"); rau (int i = 0; i = 48 && input <= 57) || breakCondition == 1 || IRNumb! = 2) {// Txheeb xyuas yog tias cov nyhuv xav tau tawm ntawm rainbowColor = colourChange (0, 0, 0); setAll (rainbowColor); breakCondition = 1; tawg; } rainbowColor = colourChange (i, 0, 0); setAll (rainbowColor); showStrip (); ncua (100); } rau (int i = 0; i = 48 && input <= 57) || breakCondition == 1 || IRNumb! = 2) {// Txheeb xyuas yog tias cov nyhuv xav tau tawm ntawm rainbowColor = colourChange (0, 0, 0); setAll (rainbowColor); breakCondition = 1; tawg; } g ++; rainbowColor = colourChange (i, g, 0); setAll (rainbowColor); showStrip (); ncua (100); } rau (int g = 0; g = 48 && input <= 57) || breakCondition == 1 || IRNumb! = 2) {// Txheeb xyuas yog tias cov nyhuv xav tau tawm ntawm rainbowColor = colourChange (0, 0, 0); setAll (rainbowColor); breakCondition = 1; tawg; } r+= 2; rainbowColor = colourChange (r, g, 0); setAll (rainbowColor); showStrip (); ncua (100); } rau (int b = 0; b = 48 && input <= 57) || breakCondition == 1 || IRNumb! = 2) {// Txheeb xyuas yog tias cov nyhuv xav tau tawm ntawm rainbowColor = colourChange (0, 0, 0); setAll (rainbowColor); breakCondition = 1; tawg; } r+= 2; g+= 5; rainbowColor = colourChange (r, g, b); setAll (rainbowColor); showStrip (); ncua (100); } mainOptions (); } lwm yog (input == '3' || IRNumb == 3) {r = 0; g yog 0;. b = 0;

Serial.println ("Sau n kom tawm");

Serial.println ("Siv w thiab s txhawm rau nce lossis txo xim liab"); Serial.println ("Siv r thiab f txhawm rau nce lossis txo xim ntsuab"); Serial.println ("Siv y thiab h kom nce lossis txo cov xim xiav"); lcd.clear (); // Ntxuav qhov screen lcd.setCursor (0, 0); lcd.print ("tawm: 0, 4/7: +/- liab"); lcd.setCursor (0, 1); lcd.print ("5/8: ntsuab, 6/9: xiav");

thaum (input2! = 'n' || IRNumb2! = 0) {

yog (Serial.available ()> 0) {// yog tus ua cim? input2 = (char) Serial.read (); } //Serial.println(IRNumb2); IRNumb2 = 10; IRScan2 ();

yog (IRNumb2 == 0) {

tawg; } yog (input2 == 'w' || IRNumb2 == 4) {r+= 2; rainbowColor = colourChange (r, g, b); setAll (rainbowColor); showStrip (); } lwm yog (input2 == 's' || IRNumb2 == 7) {r- = 2; rainbowColor = colourChange (r, g, b); setAll (rainbowColor); showStrip (); } lwm yog (input2 == 'r' || IRNumb2 == 5) {g+= 2; rainbowColor = colourChange (r, g, b); setAll (rainbowColor); showStrip (); } lwm yog (input2 == 'f' || IRNumb2 == 8) {g- = 2; rainbowColor = colourChange (r, g, b); setAll (rainbowColor); showStrip (); }

lwm yog (input2 == 'y' || IRNumb2 == 6) {

b+= 2; rainbowColor = colourChange (r, g, b); setAll (rainbowColor); showStrip (); }

lwm tus yog (input2 == 'h' || IRNumb2 == 9) {

b- = 2; rainbowColor = colourChange (r, g, b); setAll (rainbowColor); showStrip (); }} mainOptions (); } setAll (rainbowColor); showStrip (); } tsis muaj dabtsis showStrip () {pixels.show (); } void setAll (uint32_t xim) {rau (int i = 0; kuv <NUMPIXELS; kuv ++) {pixels.setPixelColor (i, xim); }} // Sau tus nqi 0 txog 255 kom tau txais tus nqi xim. uint32_t colourChange (int r, int g, int b) {rov qab pixels. Color (r, g, b); } void mainOptions () {// Sjows cov txiaj ntsig tseem ceeb xaiv lcd.clear (); // Ntxuav qhov screen lcd.setCursor (0, 0); lcd.print ("0 Rau Teeb"); lcd.setCursor (0, 1); lcd.print ("1: Lub Teeb Dawb"); ncua (1000); lcd.clear (); // Ntxuav qhov screen lcd.setCursor (0, 0); lcd.print ("2: Xim xim"); lcd.setCursor (0, 1); lcd.print ("3: Phau Ntawv Qhia"); ncua (1000); } tsis muaj nuj nqis IRScan () {yog (irrecv.decode (& cov txiaj ntsig)) {

yog (results.value == 0XFFFFFFFF)

cov txiaj ntsig.value = key_value; lwm tus {//Serial.println(results.value, HEX); yog (results.value == 0xFF6897 || results.value == 0xC101E57B) {IRNumb = 0; //Serial.println("0 "); } lwm qhov yog (cov txiaj ntsig.value == 0x9716BE3F || results.value == 0xFF30CF) {IRNumb = 1; //Serial.println("1 "); } lwm qhov yog (cov txiaj ntsig.value == 0x3D9AE3F7 || results.value == 0xFF18E7) {IRNumb = 2; //Serial.println("2 "); } lwm yog (cov txiaj ntsig.value == 0xFF7A85 || cov txiaj ntsig.value == 0x6182021B) {IRNumb = 3; // Serial.println ("3"); } lwm yog (cov txiaj ntsig.value == 0x8C22657B || results.value == 0xFF10EF) {IRNumb = 4; //Serial.println("4 "); } lwm tus yog (cov txiaj ntsig.value == 0xFF38C7 || results.value == 0x488F3CBB) {IRNumb = 5; // Serial.println ("5"); } lwm yog (cov txiaj ntsig.value == 0x449E79F || results.value == 0xFF5AA5) {IRNumb = 6; // Serial.println ("6"); } lwm qhov yog (cov txiaj ntsig.value == 0xFF42BD || results.value == 0x32C6FDF7) {IRNumb = 7; //Serial.println("7 "); } lwm qhov yog (cov txiaj ntsig.value == 0x1BC0157B || results.value == 0xFF4AB5) {IRNumb = 8; //Serial.println("8 "); } lwm qhov yog (cov txiaj ntsig.value == 0xFF52AD || results.value == 0x3EC3FC1B) {IRNumb = 9; // Serial.println ("9"); }} key_value = cov txiaj ntsig.value; irrecv.resume (); }} void IRScan2 () {yog (irrecv.decode (& cov txiaj ntsig)) {

yog (results.value == 0XFFFFFFFF)

cov txiaj ntsig.value = key_value; lwm tus {// Serial.println (results.value, HEX); yog (results.value == 0xFF6897 || results.value == 0xC101E57B) {IRNumb2 = 0; //Serial.println("0 "); } lwm qhov yog (cov txiaj ntsig.value == 0x9716BE3F || results.value == 0xFF30CF) {IRNumb2 = 1; //Serial.println("1 "); } lwm yog (cov txiaj ntsig.value == 0x3D9AE3F7 || results.value == 0xFF18E7) {IRNumb2 = 2; //Serial.println("2 "); } lwm qhov yog (cov txiaj ntsig.value == 0xFF7A85 || results.value == 0x6182021B) {IRNumb2 = 3; // Serial.println ("3"); } lwm yog (cov txiaj ntsig.value == 0x8C22657B || results.value == 0xFF10EF) {IRNumb2 = 4; //Serial.println("4 "); } lwm yog (cov txiaj ntsig.value == 0xFF38C7 || results.value == 0x488F3CBB) {IRNumb2 = 5; // Serial.println ("5"); } lwm yog (cov txiaj ntsig.value == 0x449E79F || results.value == 0xFF5AA5) {IRNumb2 = 6; // Serial.println ("6"); } lwm qhov yog (cov txiaj ntsig.value == 0xFF42BD || results.value == 0x32C6FDF7) {IRNumb2 = 7; //Serial.println("7 "); } lwm qhov yog (cov txiaj ntsig.value == 0x1BC0157B || results.value == 0xFF4AB5) {IRNumb2 = 8; //Serial.println("8 "); } lwm qhov yog (cov txiaj ntsig.value == 0xFF52AD || results.value == 0x3EC3FC1B) {IRNumb2 = 9; // Serial.println ("9"); }} key_value = cov txiaj ntsig.value; irrecv.resume (); }}

Kauj ruam 5: Mounting

Mounting
Mounting

Txhawm rau teeb tsa Arduino rau tus ncej Kuv tsuas yog lo nws thiab daim ntawv qhia zaub mov uas kuv tau siv rau sab nraub qaum thiab sim npog/zais cov hlua kom nws zoo.

Pom zoo: