int dp = 4 ; // Raqamli interfeyzni 4 segmentli “dp” segmentga bog’lash
void digital_1 (void) // Birinchi displey
{
unsigned char j; //Belgisiz char
digitalWrite (c, HIGH) ; // Raqamli interfeyzdagi 5-pin yonganda, paragraf (c) yoritiladi
digitalWrite (b, HIGH) ; // paragraf b yoritiladi
for (j = 7; j <= 11; j++) // Qolgan segmentlar o’chirilsin
digitalWrite (j, LOW);
digitalWrite (dp, LOW) ; //O’nlik nuqtasi DP ni o’chirib qo’y
}
void digital_2 (void) // Ikkinchi displey
{
unsigned char j;
digitalWrite (b, HIGH);
digitalWrite (a, HIGH);
for (j = 9; j <= 11; j++)
digitalWrite (j, HIGH);
digitalWrite (dp, LOW);
digitalWrite (c, LOW);
digitalWrite (f, LOW);
}
void digital_3 (void) // Uchinchi displey
{
unsigned char j;
digitalWrite (g, HIGH);
digitalWrite (d, HIGH);
for (j = 5; j <= 7; j++)
digitalWrite (j, HIGH);
digitalWrite (dp, LOW);
digitalWrite (f, LOW);
digitalWrite (e, LOW);
}
void digital_4 (void) // To’rtni ko’rsat
{
digitalWrite (c, HIGH);
digitalWrite (b, HIGH);
digitalWrite (f, HIGH);
digitalWrite (g, HIGH);
digitalWrite (dp, LOW);
digitalWrite (a, LOW);
digitalWrite (e, LOW);
digitalWrite (d, LOW);
}
void digital_5 (void) // Beshinchi displey
{
unsigned char j;
for (j = 7; j <= 9; j++)
digitalWrite (j, HIGH);
digitalWrite (c, HIGH);
digitalWrite (d, HIGH);
digitalWrite (dp, LOW);
digitalWrite (b, LOW);
digitalWrite (e, LOW);
}
void digital_6 (void) // Oltinchi displey
{
unsigned char j;
for (j = 7; j <= 11; j++)
digitalWrite (j, HIGH);
digitalWrite (c, HIGH);
digitalWrite (dp, LOW);
digitalWrite (b, LOW);
}
void digital_7 (void) // Yettinchi displey
{
unsigned char j;
for (j = 5; j <= 7; j++)
digitalWrite (j, HIGH);
digitalWrite (dp, LOW);
for (j = 8; j <= 11; j++)
digitalWrite (j, LOW);
}
void digital_8 (void) // Sakkizinchi displey
{
unsigned char j;
for (j = 5; j <= 11; j++)
digitalWrite (j, HIGH);
digitalWrite (dp, LOW);
}
void setup ()
{
int i ; // define variables
for (i = 4; i <= 11; i++)
pinMode (i, OUTPUT) ; //Chiqish rejimini 4 dan 11 pingacha o’rnating
}
void loop ()
{
while (1)
{
digital_1 () ; // displey numbers 1
delay (2000) ; // 2s kut
digital_2 () ; // displey number 2
delay (1000); // 1s kut
digital_3 () ; // displey the number 3
delay (1000); // 1s kut
digital_4 () ; // 4 ko’rsat
delay (1000); // 1s kut
digital_5 () ; // Beshinchi displey
delay (1000); // 1s kut
digital_6 () ; // Oltinchi displey
delay (1000); // 1s kut
digital_7 () ; // Yettinchi displey
delay (1000); // 1s kut
digital_8 () ; // Sakkizinchi displey
delay (1000); // 1s kut
}
}
4)Programma kodini arduinoga yuklash uchun quyidagi rasmdagi
instrumentga sichqoncha ko’rsatkichini olib borib bosing.
Tizim kompilyatori dasturni tekshirib xatosiz bo’lsa kontrollerga yuklaydi va programma ishga tushadi. Agar dastur kodida xatolik bo’lsa kompilyator bu xatolikni qizil rang bilan yoritib ko’rsatadi. Xatolikni tuzatib dasturni qayta yuklang.
Nazorat savollari.
7 segmentli displey ishlashi qanday?
Bunday displeyning yana nechta segmentligini uchratish mumkin?
Segmentlarni yoritishni boshqarish uchun qanday kodlardan foydalaniladi?
Bunday displeylar bizga qayerlarda kerak bo’ladi deb o’ylaysiz va nega?
Laboratoriya ishining asosiy vazifasini tushuntiring?
Amaliy qism
Kod qismi
// C++ code
//
int A=1;
int B=2;
int C=3;
int D=4;
int E=5;
int F=6;
int G=7;
void setup()
{
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
pinMode(E, OUTPUT);
pinMode(F, OUTPUT);
pinMode(G, OUTPUT);
}
void loop()
{
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
delay(500);
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
delay(500);
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
//3 ni yozish
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
delay(500);
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
//4 ni yozish
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
delay(500);
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
//5 ni yozish
digitalWrite(A, LOW);
digitalWrite(B, HIGH);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
delay(500);
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
//6 ni yozish
digitalWrite(A, LOW);
digitalWrite(B, HIGH);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
delay(500);
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
//7 ni yozish
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
//8 ni yozish
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
delay(500);
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
//9 ni yozish
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
delay(500);
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
delay(500);
}
Javoblar.
7 segmentli displeyni ishlash jarayoni haqida gapriadigan bo’lsak,avvalo segment yani bo’lak yoki qism degan ma’nolarni anglatgani uchun qurilmamiz 7 ta bo’lakdan iborat ekanligi kelib chiqadi va ularni ishlashi har bir segmentlarni ishlashi bilan bog’liq ya’ni 1 raqamini hosil qilishimiz uchun ikkita segment yonishi qolganlari o’chiq turishi kerak bo’ladi.
Asosan ishlatiladigan displaylar 7,14 va 16 talik segmentlardir.
Segmentlarni ketma ket yoqishni boshqarish uchun for()siklidan,digitalWrite()funksiyasidan,pinMode()funksiyasidan va delay()funksiyasidan foydalanamiz.
Bunday displaylar bizga asosan raqamlarni hosil qilish uchun ishlatiladi va uni oddiy kalkulyator erkranida ko’rishimiz mumkin.
Labaratoriya ishini asosiy vazifasi segment display bilan yaqindan
tanishish uni ishlatib korish,unga qanday kodlar yozilishini tushinishdan iborat deb o’ylayman.
Xulosa.
Xulosa qilib aytishimiz mumkinki bu labaratoriya ishini bajarish davomida avvalo segment nima degan savolga javob topdim.Hamda bu rivojlanayotgan aXborot texnalogiyalari davrida displeylar yaratishda mana shu segmentdan foydalanar ekan.Oddiygina kalikulyator ham mana shu segmentdan foydalanib ishlaydi
Do'stlaringiz bilan baham: |