Led (inglizcha: light-emitting diode, „yorituvchi diod ) bu yarimoʻtkazgichli yorugʻlik manbai boʻlib, tokni bevosita yorugʻlikka aylantiradi
Tugma yordamida jarayon tashkil etish
Download 1.26 Mb.
|
temirovjahongir
- Bu sahifa navigatsiya:
- NC (Odatda yopiq)
- 1 – rasm
Tugma yordamida jarayon tashkil etish
Ikki turdagi tugmalar mavjud, ular quyida keltirilgan: YO'Q (Odatda ochiq) Biz asosan NO turdagi tugmalardan foydalanamiz. Bunday turda tugma holati dam oladi. Bu shunday holatda terminal ulanmaganligini anglatadi. U quyida ko'rsatilgan: Tugmani bosganimizda, terminallar elektrga ulanadi. NC (Odatda yopiq) Bu tugmaning ish holati sifatida aniqlanadi. U kontaktlarning zanglashiga olib, oqimning yuk orqali o'tishiga imkon beradi. U quyida ko'rsatilgan: NC va NO kalitlarning vaqtinchalik turi sifatida ham aniqlanadi. Amaliy qism: Led diodlar va tugma (button) yordamida quyidagi jarayyon tashkil qilindi. Jarayyon Tincercat muhitida amalga oshirildi. Ishda jarayyonni moshinaning avarenkalariga uxshatishga harakat qilindi yani tugma 1 marta bosilganda o’ng tarafga 2 marta bosilganda chap tarafga va 3 marta bosilganda umumiy o’chib yonish holatini ko’rishimiz mumkin. 1 – rasm: Jarayyon tashkil qilingan muhitning umumiy ko’rinishi 2 – rasm: Ishlash jarayyonidan Dasturning kodi quyidagicha yozilgan: int lampPin2 = 2; // the PWM pin number of the first lamp int lampPin3 = 3; // the PWM pin number of the second lamp int lampPin4 = 4; // the PWM pin number of the third lamp int buttonPin = 8; // the digital input pin number of the button int buttonState = 0; // the state of the button (LOW or HIGH) void setup() { pinMode(lampPin2, OUTPUT); // set the first lamp pin as output for PWM pinMode(lampPin3, OUTPUT); // set the second lamp pin as output for PWM pinMode(lampPin4, OUTPUT); // set the third lamp pin as output for PWM pinMode(buttonPin, INPUT); // set the button pin as input } void loop() { buttonState = digitalRead(buttonPin); // read the state of the button if (buttonState == HIGH) { // if the button is pressed analogWrite(lampPin2, 255); // set the brightness of the first lamp to maximum analogWrite(lampPin3, 255); // set the brightness of the second lamp to maximum analogWrite(lampPin4, 255); // set the brightness of the third lamp to maximum } else { // if the button is not pressed analogWrite(lampPin2, 0); // set the brightness of the first lamp to minimum analogWrite(lampPin3, 0); // set the brightness of the second lamp to minimum analogWrite(lampPin4, 0); // set the brightness of the third lamp to minimum } } Download 1.26 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling