Cov txheej txheem:

Kev Tshawb Nrhiav Xim Siv RGB LED: 4 Cov Kauj Ruam
Kev Tshawb Nrhiav Xim Siv RGB LED: 4 Cov Kauj Ruam

Video: Kev Tshawb Nrhiav Xim Siv RGB LED: 4 Cov Kauj Ruam

Video: Kev Tshawb Nrhiav Xim Siv RGB LED: 4 Cov Kauj Ruam
Video: qhia txiav duab dho duab, ua paib qho xab na(ຕັດຕໍ່ຮູບພາບ, ອອກແບບປ້າຍໂຄສະນາ) 2024, Hlis ntuj nqeg
Anonim
Kev Tshawb Nrhiav Xim Siv RGB LED
Kev Tshawb Nrhiav Xim Siv RGB LED

Koj puas tau xav tau txoj hauv kev kom pom xim ntawm ib yam khoom? Los ntawm lub teeb ci ntawm ib qho xim ntawm cov khoom thiab saib ntau npaum li cas lub teeb pom kev rov qab, koj tuaj yeem qhia qhov xim ntawm cov khoom yog dab tsi. Piv txwv li, yog tias koj ci lub teeb liab ntawm ib yam khoom liab, lub teeb ntawd yuav pom rov qab. Yog tias koj ua lub teeb xiav rau ntawm cov khoom liab, cov khoom yuav nqus qee lub teeb ntawd thiab tsawg dua ntawm nws yuav rov pom dua.

Kauj Ruam 1: Qhov Yuav Tsum Tau

Qhov Yuav Tsum Tau
Qhov Yuav Tsum Tau

Kuv siv PIC 16F887 Microcontroller, tab sis yuav luag txhua yam nrog lub plawv dhia-dav-kev hloov kho lub peev xwm yuav ua haujlwm. 1 RGB LED1 Microcontroller1 Txuj ci liab LED1 1k ohm resistor1 Photoresistor (hloov kev ua haujlwm nyob ntawm qhov pom ntawm lub teeb ci rau nws) Qee cov xov hlau Kuv tsuas xav tau microcontroller thiab RGB LED kom muaj ntau yam xim ntsuas, tab sis yog tias koj tsuas xav tau lub Circuit Court uas kuaj pom ib qho xim, koj tsis xav tau lub microcontroller - koj tsuas xav tau lub teeb ci ci ntawm cov xim uas koj xav paub. Tus txheej txheem liab liab yog "qhov taw qhia LED" - nws teeb thaum pom cov xim raug.

Kauj ruam 2: Tsim Circuit Court

Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court

Schematic yog qhov yooj yim dua, thiab hauv daim ntawv dav dav, tau qhia hauv qab no. RGB LED yog lub zog sab nraud los ntawm PWM teeb liab. Kuv muab cov kab hluav taws xob nyob ib puag ncig lub photoresistor yog li cov teeb pom kev ib puag ncig tsis nkag mus - tsuas yog lub teeb ncaj qha saum nws yuav pom.

Kauj Ruam 3: Txoj Cai

Cov cai no tau sau rau Microchip PIC 16F887, tab sis cia siab tias koj tuaj yeem tau txais lub tswv yim dav. Kuv siv lub zog ntsuas hluav taws xob built-in ntawm kuv lub rooj tsav xwm txhim kho kom sib txawv xim ntawm RGB LED (thiab nws tsis dhau mus rau tag nrho cov spectrum vim tias kuv tsis muaj 3 PWM modules, tab sis nws zoo txaus) Cov lus suav nrog. #suav nrog #suav nrog #suav nrog "ncua.c" #suav nrog #suav nrog #siv ncua (moos = 4000000) #FUSES INTRC, NOWDT, NOPUT, NOMCLR, NOPROTECT, NOCPD, NOBROWNOUT, NOIESO, NOFCMEN, NOLVP #byte CCP1CON0 byte CCP2CON = 0x1D#byte PWM1CON = 0x9Bint tus nqi = 128; int p1 = 0; int p2 = 0; void my_setup_ccp1 (int8 value) {output_low (PIN_C2); CCP1CON = value; PWM1CON = 0;} void my_setup_ccp2 (int8 value) {output_low (PIN_C1); CCP2CON = tus nqi;} // =================================== void main () {// A4 = qhov chaw muaj zog rau photodiodeoutput_high (PIN_A4); output_high (PIN_B1); teeb tsa_adc (ADC_CLOCK_INTERNAL); set_adc_channel (0); teeb tsa_adc_ports (sAN0); // Timer/cuam tshuam teeb tsa teeb tsa_interrupts (INT_TIM2) my_setup_ccp2 (CCP_PWM); teeb tsa_timer_2 (T2_DIV_BY_1, 128, 1); // teeb tsa_compare (2, COMPARE_PWM | COMPARE_TIMER2); thaum (1) {// Tiv thaiv PIC tsis txhob tsaug zog.//SET PWM DUTY CYCLE output_high (PINA) // Pin A3 yog qhov txuas photodiode yog (input (PIN_A3) == 1) output_high (PIN_A4); lwm qhov output_low (PIN_A4); // Nyeem tus nqi ntawm lub hwj chim hloov xim ntawm LED tus nqi = read_adc (); hloov (tus nqi) {rooj plaub 0: p1 = tus nqi; output_low (PIN_C0); p2 = tus nqi; tawg; rooj plaub 50: p1 = tus nqi; output_high (PIN_C0); p2 = tus nqi; tawg; rooj plaub 100: p1 = tus nqi; output_high (PIN_C0); p2 = tus nqi; tawg; rooj plaub 150: output_high (PIN_C0); p1 = 50; p2 = tus nqi; tawg; rooj plaub 200: output_low (PIN_C0); p1 = 0; p2 = tus nqi; tawg; rooj plaub 250: p1 = 0; p2 = tus nqi; output_low (PIN_C0); tawg; } p1 = tus nqi; p2 = 128 - p1; set_pwm1_duty (p1); set_pwm2_duty (p2);}}

Kauj ruam 4: Cov ntawv thov

Cov ntawv thov!
Cov ntawv thov!

Lub tshuab ntsuas xim yooj yim zoo li no tuaj yeem siv rau hauv cov neeg hlau, lossis rau cov haujlwm txias xws li sib cais legos los ntawm xim, txheeb M & Ms, lossis raws li kev pab rau qhov muag tsis pom xim. Vam tias cov lus qhia no tau pab txhim kho txoj haujlwm uas koj tau xav!:) LEDs zoo rau ntau yam….

Pom zoo: