Potensiometr. Diodni yoritish darajasini nazorat qilish


Ushbu model uchun quyidagi dastur mos keladi



Yüklə 0,82 Mb.
səhifə13/13
tarix17.06.2022
ölçüsü0,82 Mb.
#61661
1   ...   5   6   7   8   9   10   11   12   13
2-DETLINE

Ushbu model uchun quyidagi dastur mos keladi:



// RGB LEDni boshqarish. PWM uchun dasturiy ta'minot
#include
#include
volatile char pwm_counter,pwm_r,pwm_g,pwm_b;
// T0 to‘lib ketganda uzilish
ISR (TIMER0_OVF_vect)
{
if (pwm_counter++ > 163)
{
PORTB = 0x00;
pwm_counter = 0;
}
if (pwm_counter > pwm_r) PORTB |= (1 << PB1);
if (pwm_counter > pwm_g) PORTB |= (1 << PB2);
if (pwm_counter > pwm_b) PORTB |= (1 << PB3);
}
// Protsedurani mikrosaniyalarda kechiktirish
void delay_us(unsigned char time_us)
{ register unsigned char i;
for(i = 0; i < time_us; i++) // 4 tsikl
{ asm (" PUSH R0 "); // 2 tsikl
asm (" POP R0 "); // 2 tsikl
}
}
// Millisekundlarda protsedura kechikishi
void delay_ms(unsigned int time_ms)
{ register unsigned int i;
for(i = 0; i < time_ms; i++)
{ delay_us(250);
delay_us(250);
delay_us(250);
delay_us(250);
}
}
// qizil rang
void red (unsigned int time)
{
for (char a = 0; a < 165; a++)
{
pwm_r = 164 - a; //oshirish
pwm_g = 164;
pwm_b = 164;
delay_ms(time);
}
for (char a = 0; a < 165; a++)
{
pwm_r = a; //kamayish
pwm_g = 164;
pwm_b = 164;
delay_ms(time);
}
}
// Yashil rang
void green (unsigned int time)
{
for (char a = 0; a < 165; a++)
{
pwm_r = 164;
pwm_g = 164 - a;
pwm_b = 164;
delay_ms(time);
}
for (char a = 0; a < 165; a++)
{
pwm_r = 164;
pwm_g = a;
pwm_b = 164;
delay_ms(time);
}
}
// Ko‘k rang
void blue (unsigned int time)
{
for (char a = 0; a < 165; a++)
{
pwm_r = 164;
pwm_g = 164;
pwm_b = 164 - a;
delay_ms(time);

}

for (char a = 0; a < 165; a++)
{
pwm_r = 164;
pwm_g = 164;
pwm_b = a;
delay_ms(time);
}
}
// Oq rang
void white (unsigned int time)
{
for (char a = 0; a < 165; a++)
{
pwm_r = 164 - a;
pwm_g = 164 - a;
pwm_b = 164 - a;
delay_ms(time);
}
for (char a = 0; a < 165; a++)
{
pwm_r = a;
pwm_g = a;
pwm_b = a;
delay_ms(time);
}
}
// Ranglar almashinuvi
void rgb (unsigned int time)
{
for (char a = 0; a < 165; a++)
{
pwm_r = a;
pwm_b = 164 - a;
delay_ms(time);
}
for (char a = 0; a < 165; a++)
{
pwm_b = a;
pwm_g = 164 - a;
delay_ms(time);
}
for (char a = 0; a < 165; a++)
{
pwm_g = a;
pwm_r = 164 - a;
delay_ms(time);
}
}
int main (void)
{
DDRB |= (1 << PB3)|(1 << PB2)|(1 << PB1); // PB3,2,1 - chiqishlar
TCCR0 |= (1 << CS00); // Oldindan hisoblagichsiz
TIMSK |= (1 << TOIE0); // Haddan tashqari uzilish T0 ni yoqadi
sei();// Global uzilishlarni hal qilish
while(1)
{
red(5);
green(5);
blue(5);
white(10);
for(;;)
{rgb(100);}
}
}


Foydalanilgan internet resurslar.
1. https://www.youtube.com/watch?v=-sIzkVWwHrw
2. http://electrik.info/ledlight/1411-rgb-svetodiody-kak-oni-rabotayt.html
3. https://www.youtube.com/watch?v=-sIzkVWwHrw
4. http://electrik.info/ledlight/1411-rgb-svetodiody-kak-oni-rabotayt.html


LABORATORIYA ISHI UCHUN TOPSHIRIQLAR.

  1. RGB diod orqali sariq rangni hosil qiling va uni 1 sekund davomida yoqib o’chiring.

  2. RGB diod orqali qizil rangni hosil qiling va uni 5 sekund davomida yoqib o’chiring.

  3. RGB diod orqali yashil rangni hosil qiling va uni 6 sekund davomida yoqib o’chiring.

  4. RGB diod orqali pushti rangni hosil qiling va uni 1 sekund davomida yoqib o’chiring.

  5. RGB diod orqali oq rangni hosil qiling va uni 5 sekund davomida qizilga almashtiring

  6. RGB diod orqali qora rangni hosil qiling va uni 2 sekund davomida ko’kka almashtiring

  7. RGB diod orqali 3 xil rangli 5x5 matritsa hosil qiling va uni Ichida uchburchak shaklini chiqaring

  8. RGB diod orqali 3 xil rangli 6x6 matritsa hosil qiling va uni Ichida to’rtburchak shaklini chiqaring

  9. RGB diod orqali 3 xil rangli 8x8 matritsa hosil qiling va uni Ichida aylana shaklini chiqaring

  10. RGB diod orqali 3 xil rangli 9x9 matritsa hosil qiling va uni Ichida doira shaklini chiqaring

  11. RGB diod orqali 3 xil rangli 10x10 matritsa hosil qiling va uni Ichida trapetsiya shaklini chiqaring

  12. RGB diod orqali sariq rangni hosil qiling va uni 1 sekund davomida yoqib o’chiring.

  13. RGB diod orqali qizil rangni hosil qiling va uni 5 sekund davomida yoqib o’chiring.

  14. RGB diod orqali yashil rangni hosil qiling va uni 6 sekund davomida yoqib o’chiring.

  15. RGB diod orqali pushti rangni hosil qiling va uni 1 sekund davomida yoqib o’chiring.

  16. RGB diod orqali oq rangni hosil qiling va uni 5 sekund davomida qizilga almashtiring

  17. RGB diod orqali qora rangni hosil qiling va uni 2 sekund davomida ko’kka almashtiring

  18. RGB diod orqali 3 xil rangli 5x5 matritsa hosil qiling va uni Ichida uchburchak shaklini chiqaring

  19. RGB diod orqali 3 xil rangli 6x6 matritsa hosil qiling va uni Ichida to’rtburchak shaklini chiqaring

  20. RGB diod orqali 3 xil rangli 8x8 matritsa hosil qiling va uni Ichida aylana shaklini chiqaring

  21. RGB diod orqali 3 xil rangli 9x9 matritsa hosil qiling va uni Ichida doira shaklini chiqaring

  22. RGB diod orqali 3 xil rangli 10x10 matritsa hosil qiling va uni Ichida trapetsiya shaklini chiqaring

  23. RGB diod orqali sariq rangni hosil qiling va uni 4 sekund davomida yoqib o’chiring.

  24. RGB diod orqali qizil rangni hosil qiling va uni 5 sekund davomida yoqib o’chiring.

  25. RGB diod orqali yashil rangni hosil qiling va uni 2 sekund davomida yoqib o’chiring.

  26. RGB diod orqali pushti rangni hosil qiling va uni 7 sekund davomida yoqib o’chiring.

  27. RGB diod orqali oq rangni hosil qiling va uni 12 sekund davomida qizilga almashtiring

  28. RGB diod orqali qora rangni hosil qiling va uni 25 sekund davomida ko’kka almashtiring

  29. RGB diod orqali 3 xil rangli 4x4 matritsa hosil qiling va uni Ichida uchburchak shaklini chiqaring

  30. RGB diod orqali 3 xil rangli 6x6 matritsa hosil qiling va uni Ichida to’rtburchak shaklini chiqaring

  31. RGB diod orqali 3 xil rangli 8x8 matritsa hosil qiling va uni Ichida aylana shaklini chiqaring

  32. RGB diod orqali 3 xil rangli 9x9 matritsa hosil qiling va uni Ichida doira shaklini chiqaring

  33. RGB diod orqali 3 xil rangli 10x10 matritsa hosil qiling va uni Ichida trapetsiya shaklini chiqaring

Yüklə 0,82 Mb.

Dostları ilə paylaş:
1   ...   5   6   7   8   9   10   11   12   13




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin