Laboratoriyaning amaliy qismi.
Modelni yig‘ish uchun bizga quyidagilar kerak:
o
Arduino platasi
o
uch rangli LED
o
Arduino IDE dasturi, uni Arduino veb -saytidan yuklab olish mumkin.
Agar rezistorlarsiz LED ishlatilsa, bizga ham kerak:
o
Panel (doska)
o
4 ta "papa-papa" simlari
o
220 Om uchun 3 rezistor
Modelning Arduinoga ulanish sxemasi:
O‘rnatilgan rezistorlarsiz uch rangli LED bilan ishlashda shuni yodda tutish
kerakki, LED oyog‘ining maqsadi uning uzunligi bo‘yicha aniqlanishi mumkin. Eng
uzun yer (GND), qisqaroq yashil (G), hatto qisqaroq ko‘k (B) va eng qisqa qizil (R).
O‘rnatilgan rezistorlar bilan uch rangli LEDli Arduino modeli uchun ulanish
sxemasi:
// C++ code
//
int red = 12;
int blue = 10;
int green = 8;
void setup()
{
pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(green, OUTPUT);
}
void loop()
{
digitalWrite(red, HIGH);
delay(1000);
digitalWrite(blue, HIGH);
delay(1000);
digitalWrite(green, HIGH);
delay(1000);
digitalWrite(red, LOW);
delay(1000);
digitalWrite(blue, LOW);
delay(1000);
digitalWrite(green, HIGH);
delay(1000);
digitalWrite(red, LOW);
delay(1000);
digitalWrite(blue, HIGH);
delay(1000);
digitalWrite(green, LOW);
delay(1000);
digitalWrite(red, HIGH);
delay(1000);
digitalWrite(blue, LOW);
delay(1000);
digitalWrite(green, HIGH);
delay(1000);
}
|