Cov txheej txheem:

Wireless Arduino Teeb-Sib Piv LED Teeb Siv Photoresistor: 4 Cov Kauj Ruam
Wireless Arduino Teeb-Sib Piv LED Teeb Siv Photoresistor: 4 Cov Kauj Ruam

Video: Wireless Arduino Teeb-Sib Piv LED Teeb Siv Photoresistor: 4 Cov Kauj Ruam

Video: Wireless Arduino Teeb-Sib Piv LED Teeb Siv Photoresistor: 4 Cov Kauj Ruam
Video: $600 NYIAJ PAB CA * $3600 CHILD TAX * BIDEN SPEECH * INDIA KAB MOB HNYAV * TOP NEWS+ 04/29/2021 2024, Kaum ib hlis
Anonim
Wireless Arduino Teeb-Teeb LED Teeb Siv Photoresistor
Wireless Arduino Teeb-Teeb LED Teeb Siv Photoresistor
Wireless Arduino Teeb-Teeb LED Teeb Siv Photoresistor
Wireless Arduino Teeb-Teeb LED Teeb Siv Photoresistor
Wireless Arduino Teeb-Teeb LED Teeb Siv Photoresistor
Wireless Arduino Teeb-Teeb LED Teeb Siv Photoresistor

Cov lus qhia no qhia ntxaws txog cov kauj ruam tsim nyog los tsim lub rudimentary wireless teeb pom kev zoo teeb LED siv Arduino Unos thiab photoresistor. Daim ntawv thov tau rau lub cuab yeej no yuav yog teeb pom kev hauv chav uas tsis muaj lub qhov rais nrog lub hnub ci dag, sib piv qhov teeb pom kev zoo sab nraum lub sijhawm tiag tiag. Cia peb pib!

Cov Khoom Muag:

Arduino Uno x2 os

NRF24L01 Wireless transceiver x2 (Yeem - NRF24L01 hnab ev khoom x2)

TIP120 darlington transistor

Photoresistor

5 hli LEDs x3

Pushbutton

100 ohm resistor x3

10 k ohm resistor x3

Ntau Yam Jumper Wires

Kauj Ruam 1: Txuas NRF24L01 Modules thiab Circuit

Txuas lub NRF24L01 Modules thiab Circuit
Txuas lub NRF24L01 Modules thiab Circuit
Txuas lub NRF24L01 Modules thiab Circuit
Txuas lub NRF24L01 Modules thiab Circuit
Txuas lub NRF24L01 Modules thiab Circuit
Txuas lub NRF24L01 Modules thiab Circuit

Hauv txoj haujlwm no, ib tus Arduino yuav ua tus xa khoom, xa cov ntaub ntawv teeb pom kev los ntawm tus kws yees duab thaum lub khawm nias. Lwm qhov Arduino yuav ua tus txais, nqa cov ntaub ntawv ntawd thiab hloov nws mus rau hauv lub teeb liab mus rau LEDs. Thawj daim duab qhia pom daim duab xa xov, thiab daim duab thib ob qhia tus txais.

Nco tseg: hauv cov duab ntawm kuv qhov haujlwm, koj yuav pom lub NRF24L01 cov xa xov txuas nrog lwm tus PCB. Nov yog lub hnab ntim khoom rau lub transceivers, uas ua raws li lub zog tswj hwm. Ntxiv rau ua kom txuas xov yooj yim dua, cov hnab ev ntawv tswj hwm lub zog tawm tswv yim rau NRF24L01, tso cai siv lub zog 5V. Kuv tau tso cov hnab ev ntawv hauv kuv daim duab rau qhov pom tseeb.

(Yog tias koj txiav txim siab siv lub hnab ev khoom, thov mus saib qhov txuas no rau daim duab ntawm tus pin chaw nyob hauv qhov siv rau hauv Tshuag NRF24L01).

Txuas hauv qab no yog daim ntawv theej PDF ntawm kab ntawv, kom yooj yim dua zooming/ntxaws saib.

Kauj ruam 2: Coding tus Transmitter

Kauj ruam kawg yog coding. Koj yuav tsum tau teeb tsa RadioHead lub tsev qiv ntawv lossis lub tsev qiv ntawv sib npaug rau siv nrog NRF24L01 cov qauv.

Rau txoj haujlwm no, tus xa thiab txais Arduinos siv cov lej sib txawv ntawm txhua tus. Nov yog tus lej rau tus xa tawm:

Kuv kuj tau txuas cov ntaub ntawv.ino (NRF_Send) kom yooj yim.

#suav nrog

#suav nrog

RH_NRF24 nrf24; // Initializing tus transceiver li nrf24

int khawm = 5; // Teeb tus lej tus lej rau khawm thiab photoresistor

int pResistor = A0; int tus nqi = 0; // Tus nqi ntawm lub teeb los ntawm 0-1023

void teeb tsa ()

{Serial.begin (9600); pinMode (khawm, INPUT); pinMode (pResistor, INPUT); yog (! nrf24.init ()) // Ceeb toom rau tus neeg siv yog tias kev pib ua haujlwm ntawm tus qauv tsis ua tiav Serial.println ("pib ua tsis tiav"); // Qhov pib tom qab pib yog 2.402 GHz (channel 2), 2Mbps, 0dBm yog (! Nrf24.setChannel (1)) Serial.println ("setChannel ua tsis tau"); yog (! nrf24.setRF (RH_NRF24:: DataRate2Mbps, RH_NRF24:: TransmitPower0dBm)) Serial.println ("setRF ua tsis tau tejyam"); }

void lub voj ()

{yog (digitalRead (khawm)) {// Xa lus yog tias lub pob raug nias tus nqi = analogRead (pResistor); // Nyeem tus nqi ntawm photoresistor (0-1023) uint8_t cov ntaub ntawv = {tus nqi}; // Teeb tsa ib qho array hu ua "data " uas muaj lub teeb pom kev nrf24.send (cov ntaub ntawv, sizeof (cov ntaub ntawv)); // Xa cov array mus rau tus neeg txais nrf24.waitPacketSent (); // Tos kom txog thaum lub pob ntawv tau xa Serial.println ("Lub teeb pom kev:" +Txoj hlua (tus nqi)); // Luam lub teeb pom kev rau hauv qhov saib xyuas}}

Kauj Ruam 3: Coding Tus Txais

Rau tus txais, tus lej tseem siv RadioHead Library.

#suav nrog

#suav nrog

RH_NRF24 nrf24;

int LEDPin = 3;

int tus nqi = 0; // Tus nqi ntawm lub teeb los ntawm 0-1023

void teeb tsa ()

{Serial.begin (9600); tus pinMode (LEDPin, OUTPUT); yog (! nrf24.init ()) Serial.println ("init ua tsis tau tejyam"); // Qhov pib tom qab pib yog 2.402 GHz (channel 2), 2Mbps, 0dBm yog (! Nrf24.setChannel (1)) Serial.println ("setChannel ua tsis tau"); yog (! nrf24.setRF (RH_NRF24:: DataRate2Mbps, RH_NRF24:: TransmitPower0dBm)) Serial.println ("setRF ua tsis tau tejyam"); }

void lub voj ()

{// Tos rau cov lus uint8_t buf [RH_NRF24_MAX_MESSAGE_LEN]; // Khaws cov lus tau txais raws li kab lus hu ua "buf " uint8_t len = sizeof (buf); // Khaws qhov loj ntawm buf li "len" thaum (nrf24.waitAvailableTimeout (200) && nrf24.recv (buf, & len)) // Tau txais cov lus rau 200 milliseconds lossis txog thaum tag nrho cov lus tau txais {tus nqi = buf [0]; // Teeb tus nqi rau thawj qhov ntsuas ntawm buf , uas yog int los ntawm photoresistor analogWrite (LEDPin, daim ntawv qhia (tus nqi, 0, 1023, 0, 255)); // Teeb tus pin PWM kom tso tawm tus lej ntsuas ntawm 0-255 rau LED ci ci Serial.println (Txoj hlua (tus nqi)); } analogWrite (LEDPin, 0); }

Kauj ruam 4: Ua tiav

Txaus siab rau ua si ib puag ncig nrog qib sib txawv thiab saib cov LEDs sib phim lawv! Tus photoresistor tuaj yeem ua rau qee zaum tsis zoo, thiab ua haujlwm zoo tshaj plaws hauv chav tsaus nrog lub teeb pom kev hauv ib puag ncig (tab sis tuaj yeem ua haujlwm sab nraud nrog lub hnub ib yam nkaus).

Pom zoo: