O‘ZBEKISTON RESPUBLIKASI RAQAMLI TEXNALOGIYALAR
VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT
TEXNOLOGIYALARI UNIVERSITETI
SAMARQAND FILIALI
"Kompyuter tizimlari" fakulteti
"Kompyuter tizimlari " kafedrasi
AMALIY ISH-1
,,O’rnatilgan Tizimlar “
fanidan
GURUH: KI_21-15
TALABA: Abdug’aniyev N
QABUL QILDI:
Mirsaidov B
SAMARQAND 2023-2024
Mavzu:
1-topshiriq
Ishdan maqsad:
Talabalarga Arduino mikrokantrolleri va uning datchiklar
haqida ma’lumot berish. Ular bilan ishlash ko‘nikmalarini hosil qilish
№
Topshiriq mavzusi
1
1. 5 ta led chirog‘ini ketma ket yoqish va o‘chish tartibida chiqarish
2. Tugma bosilganda 2ta svetodiod yonsin , bosilmaganda boshqa 2ta svetodiod
yonsin.
Dastur Kodi
// Pinlar
const int LED1 = 2;
const int LED2 = 3;
const int LED3 = 4;
const int LED4 = 5;
const int LED5 = 6;
// Setup funksiyasi
void setup() {
// Pinlarni OUTPUT rejimiga o‘rnatish
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
}
// Asosiy dastur
void loop() {
// 1. LEDni yoqish
digitalWrite(LED1, HIGH);
delay(1000); // 500 millisekund kutamiz
// 1. LEDni o‘chirish va 2. LEDni yoqish
digitalWrite(LED1, LOW);
digitalWrite(LED2, HIGH);
delay(1000);
// 2. LEDni o‘chirish va 3. LEDni yoqish
digitalWrite(LED2, LOW);
digitalWrite(LED3, HIGH);
delay(1000);
// 3. LEDni o‘chirish va 4. LEDni yoqish
digitalWrite(LED3, LOW);
digitalWrite(LED4, HIGH);
delay(1000);
// 4. LEDni o‘chirish va 5. LEDni yoqish
digitalWrite(LED4, LOW);
digitalWrite(LED5, HIGH);
delay(1000);
// 5. LEDni o‘chirish
digitalWrite(LED5, LOW);
delay(1000);
}
2. Tugma bosilganda 2ta svetodiod yonsin , bosilmaganda boshqa 2ta svetodiod yonsin
.
Dastur kodi.
// Pinlar
const int BUTTON_PIN = 2; // Tugma pin
const int LED1 = 3; // Birinchi LED pin
const int LED2 = 4; // Ikkinchi LED pin
const int LED3 = 5; // Uchinchi LED pin
const int LED4 = 6; // To'rtinchi LED pin
// Oldingi tugma holati
int previousButtonState = LOW;
// Tugma holati
int buttonState = LOW;
// Setup funksiyasi
void setup() {
pinMode(BUTTON_PIN, INPUT); // Tugma pinini kirishga o'rnating
pinMode(LED1, OUTPUT); // Birinchi LED pinini chiqishga o'rnating
pinMode(LED2, OUTPUT); // Ikkinchi LED pinini chiqishga o'rnating
pinMode(LED3, OUTPUT); // Uchinchi LED pinini chiqishga o'rnating
pinMode(LED4, OUTPUT); // To'rtinchi LED pinini chiqishga o'rnating
}
// Asosiy dastur
void loop() {
// Tugmani o'qish
buttonState = digitalRead(BUTTON_PIN);
// Tugma olib tashlanganligini tekshirish
if (buttonState != previousButtonState) {
// Tugma bosilganda
if (buttonState == HIGH) {
// Birinchi 2 LEDni yoqish
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
// Qolgan 2 LEDni o'chirish
digitalWrite(LED3, LOW);
digitalWrite(LED4, LOW);
} else { // Tugma bosilmaganda
// Qolgan 2 LEDni yoqish
digitalWrite(LED3, HIGH);
digitalWrite(LED4, HIGH);
// Birinchi 2 LEDni o'chirish
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
}
}
// Tugma holatini saqlash
previousButtonState = buttonState;
}
|