Guruh talabasi Amirov Asadbek Avtomatlashtirilgan loyihalash tizimlari. Modul




Download 2,09 Mb.
Sana24.11.2023
Hajmi2,09 Mb.
#104795
Bog'liq
Asadbek 3 Avtomatlashtirilgan loyihalash tizimlarida dasturlash


110-20 guruh talabasi Amirov Asadbek


Avtomatlashtirilgan loyihalash tizimlari.

  1. Modul



  1. rasm. Basit bir LED-ni yoqish va o'chirish. Arduinoga bir LED va 220 ohmlik resistor ulang. LED-ni yoqish va o'chirish uchun digitalWrite() funktsiyasidan foydalaning.

// Pin raqamini o'zingiz tanlang
const int ledPin = 13; // Masalan, 13-no'li pin


void setup() {
// LED-ni chiqaruvchi pin sifatida o'rnating
pinMode(ledPin, OUTPUT);
}


void loop() {
// LED-ni 1 sekund mobaynida yoqish
digitalWrite(ledPin, HIGH);
delay(1000);


// LED-ni o'chirish
digitalWrite(ledPin, LOW);
delay(1000);
}



2-rasm. Arduino platasi svetadiodning davrini T=1s qilib yoqib o`chiraylik ya`ni 1s
vaqt mobaynida svetadiod 1 marta to`liq yonib o`chsin.

int LED = 7;


int bnt = 5;

void setup() {


pinMode(LED, OUTPUT);
pinMode(bnt, INPUT_PULLUP);
digitalWrite(LED, LOW);
}

void loop() {


// put your main code here, to run repeatedly:
if (digitalRead(bnt) == LOW) {
digitalWrite(LED, HIGH);
delay(3600);
digitalWrite(LED, LOW);
delay(500);
digitalWrite(LED, HIGH);
delay(3000);
digitalWrite(LED, LOW);
}
}

3-rasm. Do, re, mi ohangini zummerda hosil qiling. Yarim soniga vaqt oralig`i bilan 2 ta svetadiod oling (biri qizil biri yashil) yashil svetadiod yonganda do ohangi chalinsin, qizil svetadiod yonganda si ohangi chalinsin . Vaqt oralig`I sifati 1 soniya olasiz.


// Pin raqamlarini o'zingiz tanlang
const int buzzerPin = 8; // Zummer uchun pin (masalan, 8-no'li pin)
const int redLedPin = 12; // Qizil LED uchun pin (masalan, 12-no'li pin)
const int greenLedPin = 11; // Yashil LED uchun pin (masalan, 11-no'li pin)


void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
pinMode(greenLedPin, OUTPUT);
}


void loop() {
// Do ohangi
playNote(262); // Do notasiyasi


// Yarim sona kuzatish
delay(500);


// Re ohangi
playNote(294); // Re notasiyasi


// Yarim sona kuzatish
delay(500);


// Mi ohangi
playNote(330); // Mi notasiyasi


// Yarim sona kuzatish
delay(500);

// Yashil LEDni yoqish, qizil LEDni o'chirish
digitalWrite(greenLedPin, HIGH);
digitalWrite(redLedPin, LOW);

// Yarim sona kuzatish
delay(500);

// Yashil LEDni o'chirish, qizil LEDni yoqish
digitalWrite(greenLedPin, LOW);
digitalWrite(redLedPin, HIGH);


// Yarim sona kuzatish
delay(500);
}


// Zummerda notani ijro etish uchun funksiya
void playNote(int noteFrequency) {
tone(buzzerPin, noteFrequency, 500); // 500 millisekund davomida notani ijro etish
delay(50); // Nota orasida keyin 50 millisekund kuzatish
}



4-rasm. Do, re, mi, fa, sol, la, si ohanglarini zummerda hosil qiling. Yarim soniya vaqt oralig`i bilan svetadiodda har bir ohanglar akslansin.


// Pin raqamlarini o'zingiz tanlang
const int buzzerPin = 8; // Zummer uchun pin (masalan, 8-no'li pin)
const int numLEDs = 7; // Svetadiodlar soni
int ledPins[] = {2, 3, 4, 5, 6, 7, 9}; // Svetadiodlar uchun pin raqamlari


// Notalar
int notes[] = {262, 294, 330, 349, 392, 440, 494};


void setup() {
pinMode(buzzerPin, OUTPUT);
for (int i = 0; i < numLEDs; i++) {
pinMode(ledPins[i], OUTPUT);
}
}


void loop() {
for (int i = 0; i < 7; i++) {
playNote(notes[i]);
flashLED(i);
}
}


// Zummerda notani ijro etish uchun funksiya
void playNote(int noteFrequency) {
tone(buzzerPin, noteFrequency, 500); // 500 millisekund davomida notani ijro etish
delay(50); // Nota orasida keyin 50 millisekund kuzatish
}


// LEDni yoritish va o'chirish uchun funksiya
void flashLED(int ledIndex) {
digitalWrite(ledPins[ledIndex], HIGH);
delay(500); // 1/2 sekund
digitalWrite(ledPins[ledIndex], LOW);
delay(50); // Nota orasida keyin 50 millisekund kuzatish
}



5-rasm. Yangi yil musiqasini zummer musiqasini yarating.


// Pin raqamlarini o'zingiz tanlang
const int buzzerPin = 8; // Zummer uchun pin (masalan, 8-no'li pin)


void setup() {
pinMode(buzzerPin, OUTPUT);
}


void loop() {
playNote(329); // Mi notasiyasi
delay(500);


playNote(329); // Mi notasiyasi
delay(500);


playNote(329); // Mi notasiyasi
delay(1000);


playNote(329); // Mi notasiyasi
delay(500);


playNote(329); // Mi notasiyasi
delay(500);


playNote(329); // Mi notasiyasi
delay(1000);


playNote(329); // Mi notasiyasi
delay(500);


playNote(391); // Sol notasiyasi
delay(500);


playNote(261); // Do notasiyasi
delay(500);


playNote(329); // Mi notasiyasi
delay(500);


playNote(391); // Sol notasiyasi
delay(500);


playNote(440); // La notasiyasi
delay(1000);


playNote(329); // Mi notasiyasi
delay(500);


playNote(329); // Mi notasiyasi
delay(500);


playNote(329); // Mi notasiyasi
delay(1000);


playNote(329); // Mi notasiyasi
delay(500);


playNote(391); // Sol notasiyasi
delay(500);


playNote(261); // Do notasiyasi
delay(500);


playNote(329); // Mi notasiyasi
delay(500);


playNote(391); // Sol notasiyasi
delay(500);


playNote(440); // La notasiyasi
delay(1000);
}


// Zummerda notani ijro etish uchun funksiya
void playNote(int noteFrequency) {
tone(buzzerPin, noteFrequency, 500); // 500 millisekund davomida notani ijro etish
delay(50); // Nota orasida keyin 50 millisekund kuzatish
}
Download 2,09 Mb.




Download 2,09 Mb.

Bosh sahifa
Aloqalar

    Bosh sahifa



Guruh talabasi Amirov Asadbek Avtomatlashtirilgan loyihalash tizimlari. Modul

Download 2,09 Mb.