Ta yetti segmentli indikatordan tashkil topgan razryadli matritsa. Dinamik aks ettirishni amalga oshirish (Arduinoda) Ishdan maqsad


Download 0.63 Mb.
Sana18.06.2023
Hajmi0.63 Mb.
#1576733
Bog'liq
8-labaratoriya


8 – Laboratoriya ishi
7 ta yetti segmentli indikatordan tashkil topgan 4 razryadli matritsa. Dinamik aks ettirishni amalga oshirish (Arduinoda)
Ishdan maqsad: Arduino platformasida ma’lumotlarni namoyish qilish uchun
4-bitli yetti segmentli matritsani ishlash imkoniyatini o’rganish.
Kerakli komponentlar:
Arduino UNO platformasi;
• kompanentlarni ulash uchun maket platasi;
• 4-bitli yetti segmentli matritsa;
• qarshilik 510 Ohm - 8 dona;
• knopka;
• qarshilik 10 kOm;
• Ulovchi simlar.
Yetti segmentli ko'rsatkichlarning 4 xonali matritsasi to'rtta yetti segment displeylaridan iborat va matritsada bir vaqtning o'zida 4 ta raqamni namoyish qilish uchun mo'ljallangan, shuningdek, o'nli kasrni ko'rsatish imkoniyati mavjud. 7 segmentli displeylarda 4-bitli matritsaning diagrammasi shakl. 8.1.

8.1-rasm. 7 segmentli displeylarda 4-bitli matritsaning sxemasi
Raqamni ko'rsatish uchun siz A - G va DP pinlariga kerakli displeylarni yoqishingiz va 6, 8, 9 yoki 12 pinlariga LOW berish orqali kerakli matritsani tanlashingiz kerak. Matritsa kontaktlarini Arduino platasiga ulang va sonlarni matritsaning turli bitlariga chiqaring. Ulanish uchun bizga 12 ta Arduino pini kerak. 4-bitli matritsani Arduino platasiga ulash uchun simlar diagrammasi shakl. 8.2. Kontaktlarni ulashda 510 ohm cheklash rezistorlari ishlatiladi.

8.2-rasm. Arduino-ga 4-bitli matritsani ulash sxemasi
Matritsaning o'zboshimchalik bilan ro'yxatga olinishiga (0-9) raqamlarning ketma-ket chiqishi eskizini yozamiz. Biror qatordan tasodifiy qiymatni tanlash uchun biz random () funktsiyasidan foydalanamiz. Raqamlar [] qatori 0-9 raqamlarini ko'rsatish uchun ma'lumotlarga mos keladigan qiymatlarni saqlaydi (baytning eng muhim biti indikator segmenti A yorlig'iga, eng kami - G segmentiga to'g'ri keladi), pinlar [] qatori A - G va DP segmentlari uchun pin qiymatlarini o'z ichiga oladi array pindigits [] - matritsa bitini tanlash uchun kontaktlarning qiymatlari.

8.3-rasm. Sxemaning kodi
8.4-rasm. Arduino-ga matritsani ulash sxemasi


8.5-rasm. Arduino-ga matritsani ulash sxemasi va ishlash jarayoni


8.6-rasm. Arduino-ga matritsani ulash sxemasi va ishlash jarayoni

DASTUR KODI:
import muvium.compatibility.arduino.*;

//Yusupov Azizbek KI 11-19


public class Class0 extends Arduino{
int segA = 1;
int segB = 2;
int segC = 3;
int segD = 4;
int segE = 5;
int segF = 6;
int segG = 7;
public void setup(){
for(int pin=1; pin <= 8; pin++)
pinMode(pin, OUTPUT);

}

// the loop() method runs over and over again,


// as long as the Arduino has power
public void loop(){
/* for(int pin=9; pin >= 0; pin--)
{
digitalWrite(pin, HIGH);
delay(500);
digitalWrite(pin, LOW);

}
*/


// Your loop code goes here
for (int d = 9; d >= 0; d--)
{
writeDigital(d);
delay(1000);

}

}


void writeDigital(int digital)
{
switch(digital)
{
case 9:
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
case 8:
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
case 7:
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, LOW);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, LOW);
break;
case 6:
digitalWrite(segA, HIGH);
digitalWrite(segB, LOW);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
case 5:
digitalWrite(segA, HIGH);
digitalWrite(segB, LOW);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
case 4:
digitalWrite(segA, LOW);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, HIGH);
break;
case 3:
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, HIGH);
break;
case 2:
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, LOW);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, LOW);
digitalWrite(segG, HIGH);
break;
case 1:
digitalWrite(segA, LOW);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, LOW);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, LOW);
break;
case 0:
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, LOW);
break;
}
}
}
Download 0.63 Mb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling