2 - Laboratoriya mashg’uloti nomi:
Yorug’lik diodi. Arduino yordamida yorug’lik diodini o’chirib yoqish.
Topshiriq:
17 - variant
Led pin 4; On time 400; Off time 600:
Ulanish sxemasi
Dastur kodi va ulanish sxemasi
Dastur kodi:
void setup()
{
pinMode(4, OUTPUT);
}
void loop()
{
digitalWrite(4, HIGH);
delay(400);
digitalWrite(4, LOW);
delay(600);
}
Nazorat savollariga javoblar
void - bu C, C++, Java, C#, Objective-C, D, ActionScript va PHP dasturlash tillarida tur, tur spetsifikatsiyasi va kalit so'z.
Arduino-dagi pinMode o'qish yoki yozish operatsiyalarini bajarish uchun pinning ishlash rejimini o'rnatishga yordam beradi. Odatda, bu funksiya setup() usuli ichida ishlatiladi va dastur ishga tushganda bir marta bajariladi. Arduino kirish va chiqish rejimini noto'g'ri sozlash loyiha va plataning ishlashiga ta'sir qilishi mumkin.
Funktsiya ish kuchlanishini (ko'p hollarda 5V) pinlarga qo'llash yoki olib tashlash orqali ulangan Arduino uskunasini boshqarishga imkon beradi. Aslini olganda, digitalWrite Arduino-ni bizning vazifalarimizga qarab portlarida kuchlanishni yoqadigan yoki o'chiradigan katta aqlli rozetkaga aylantiradi.
Arduino kechikishi eng oddiy buyruq bo'lib, ko'pincha yangi boshlanuvchilar tomonidan qo'llaniladi. Aslida, bu qavslarda ko'rsatilgan millisekundlar soni uchun dasturni to'xtatib turadigan kechikishdir. (Bir soniyada 1000 millisekund bor.) Maksimal qiymat 4294967295 ms bo'lishi mumkin, bu taxminan 50 kunga teng.
XULOSA
Men bu laboratoriya ishini bajarib ARDUINO, led lampochka, resistor haqida bir qancha bilimlarga ega bo’ldim. Arduino yordamida yorug’lik diodini o’chirib yoqishni o’rgandim va bir qancha nazariy savollarga javob topdim.
3 - LABORATORIYA MASHG‘ULOTI NOMI:
Tugma (Knopka). Yorug‘lik diodini yoqish misolida tugmaning bosilishiga ishlov berish. Titrashga qarshi kurashish.
17 – variant
Led pin 4; button pin 6:
ULANISH SXEMASI
DASTUR KODI
void setup()
{
pinMode(4, OUTPUT);
pinMode(6, INPUT);
digitalWrite(6, HIGH);
}
void loop()
{
int buttonState=digitalRead (6);
if(buttonState==1){
digitalWrite(4, HIGH);
}else{
digitalWrite(4, LOW);
}
}
4 - LABORATORIYA MASHG‘ULOTI NOMI:
Potensiometr. Arduino orqali yorug‘lik diodini yorug‘lik darajasini o‘zgartirishini namoyish etish.
ULANISH SXEMASI
DASTUR KODI
int LED_PIN = 5;
void setup()
{
Serial.begin(9600);
pinMode(5, OUTPUT);
}
void loop()
{
int analogValue = analogRead(A3);
int brightness = map(analogValue, 0, 1023, 0, 255);
analogWrite(5, brightness);
Serial.print("Analog:");
Serial.print(analogValue);
Serial.print("Brightness:");
Serial.println(brightness);
delay(100);
}
5-LABORATORIYA MASHG‘ULOTI NOMI:
Potensiometrni harakatlantirish orqali yonayotgan yorug‘lik diodining sonini o‘zgartirish.
ULANISH SXEMASI
DASTUR KODI:
#define LED_1_PIN 5
#define LED_2_PIN 9
#define LED_3_PIN 10
#define POTENTIOMETER_PIN A3
#define LED_NUMBER 3
void setup()
{
pinMode(LED_1_PIN, OUTPUT);
pinMode(LED_2_PIN, OUTPUT);
pinMode(LED_3_PIN, OUTPUT);
}
void loop()
{
int potentiometerValue = analogRead(POTENTIOMETER_PIN);
int ledChoice = potentiometerValue/(1024/LED_NUMBER);
if(ledChoice>LED_NUMBER-1){
ledChoice=LED_NUMBER-1;
}
if(ledChoice==0){
digitalWrite(LED_1_PIN, HIGH);
digitalWrite(LED_2_PIN, LOW);
digitalWrite(LED_3_PIN, LOW);
}
else if(ledChoice==1){
digitalWrite(LED_1_PIN, LOW);
digitalWrite(LED_2_PIN, HIGH);
digitalWrite(LED_3_PIN, LOW);
}
else{
digitalWrite(LED_1_PIN, LOW);
digitalWrite(LED_2_PIN, LOW);
digitalWrite(LED_3_PIN, HIGH);
}
}
Do'stlaringiz bilan baham: |