1-vazifa: rgb led bilan tanishish va uni loyihalarda ishlatish


-qadam. Bu qadamda laboratoriya ishini amaliyotda qo’llash uchun elektron sxemasi chizamiz (1.2-chizmada keltirilgan). 3-qadam



Download 3,2 Mb.
bet6/6
Sana13.06.2022
Hajmi3,2 Mb.
#661165
1   2   3   4   5   6
Bog'liq
zarif jorayev 2 labaratoriya

2-qadam. Bu qadamda laboratoriya ishini amaliyotda qo’llash uchun elektron sxemasi chizamiz (1.2-chizmada keltirilgan).

3-qadam. Laboratoriya ishining strukturaviy va elektron sxemasi yordamida Tinkercad.com platformasida ishni emulatsion formasini xosil qilamiz(1.3-chizma).

Kodi:
const byte SEGMENT_PINS[8] = {9, 8, 7, 6, 2, 3, 4, 5};
const byte POWER_PINS[4] = {10, 11, 12, 13};
const byte SEGMENT_LENGTH = sizeof(SEGMENT_PINS) / sizeof(byte);
const byte POWER_LENGTH = sizeof(POWER_PINS) / sizeof(byte);
const unsigned int SEGMENTS[8] = {
// middle
1 << 0,
// top left
1 << 1,
// top
1 << 2,
// top right
1 << 3,
// dot
1 << 4,
// bottom right
1 << 5,
// bottom
1 << 6,
// bottom left
1 << 7
};
const unsigned int DIGITS[10] = {
(SEGMENTS[1] | SEGMENTS[2] | SEGMENTS[3] | SEGMENTS[5] | SEGMENTS[6] | SEGMENTS[7]),
(SEGMENTS[3] | SEGMENTS[5]),
(SEGMENTS[0] | SEGMENTS[2] | SEGMENTS[3] | SEGMENTS[6] | SEGMENTS[7]),
(SEGMENTS[0] | SEGMENTS[2] | SEGMENTS[3] | SEGMENTS[5] | SEGMENTS[6]),
(SEGMENTS[0] | SEGMENTS[1] | SEGMENTS[3] | SEGMENTS[5]),
(SEGMENTS[0] | SEGMENTS[1] | SEGMENTS[2] | SEGMENTS[5] | SEGMENTS[6]),
(SEGMENTS[0] | SEGMENTS[1] | SEGMENTS[2] | SEGMENTS[5] | SEGMENTS[6] | SEGMENTS[7]),
(SEGMENTS[2] | SEGMENTS[3] | SEGMENTS[5]),
(SEGMENTS[0] | SEGMENTS[1] | SEGMENTS[2] | SEGMENTS[3] | SEGMENTS[5] | SEGMENTS[6] | SEGMENTS[7]),
(SEGMENTS[0] | SEGMENTS[1] | SEGMENTS[2] | SEGMENTS[3] | SEGMENTS[5] | SEGMENTS[6])
};
unsigned int x = 0;
void setup() {
byte length;
for (byte i = 0; i < POWER_LENGTH; i++) {
pinMode(POWER_PINS[i], OUTPUT);
digitalWrite(POWER_PINS[i], LOW);
}
for (byte i = 0; i < SEGMENT_LENGTH; i++) {
pinMode(SEGMENT_PINS[i], OUTPUT);
digitalWrite(SEGMENT_PINS[i], HIGH);
}
}void loop() {
x %= 10000;
for (byte k = 0; k < POWER_LENGTH; k++) {
for (byte j = 0; j < (100 / POWER_LENGTH); j++) { // loop 4 digits
unsigned int y = 1;
for (byte i = 0; i < POWER_LENGTH; i++) {
y *= 10;
setLED(POWER_PINS[i], DIGITS[(x / (y / 10)) % 10] | ((k == i) ? SEGMENTS[4] : 0));
}
delay(2);
}
}
x++;
}void setLED(byte powerPin, unsigned int segmentValue, bool enabled) {
digitalWrite(powerPin, enabled ? HIGH : LOW);
for (byte i = 0; i < SEGMENT_LENGTH; i++) {
if ((segmentValue & SEGMENTS[i]) > 0) {
digitalWrite(SEGMENT_PINS[i], enabled ? LOW : HIGH);
}
}
delay(1);
}void setLED(byte powerPin, unsigned int segmentValue) {
setLED(powerPin, segmentValue, true);
setLED(powerPin, segmentValue, false);
}
Dastur linki::https://www.tinkercad.com/things/8tUmE82Uin8-copy-of-7-segment-4-digit-led-display/editel?sharecode=8R8QSm1f6zbECJeQAj8tV8dc_LbaLZDlNDupmceGKZo
Download 3,2 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish