Asboblar va materiallar.
5 dona 5 mm LED yoki 3 mm LED (erkin rang)
5 dona rezistorlar 100 Ohm
6 dona o'tkazgich kabellari
1 dona Protoboard
1 dona Arduino
Arduino UNO yordamida ishlaydigan yorug'lik davri (LED).
Tavsif.
Arduino GND Pin (qora) dan GND/CATHODE LED0, 1, 2, 3 va 4 (qora)
Pin 4 (yashil) rezistorga
3-pin (to'q sariq) rezistorga
Pin 2 (qizil rang) rezistorga
1-pin (binafsha rang) rezistorga
Pin 0 (ko'k) rezistorga
Barcha rezistorlarning boshqa tomoni musbat LEDga ulangan (1 LED = 1 qarshilik va boshqalar)
Eskiz dasturlari.
Arduino UNO-dan foydalangan holda ishlaydigan chiroqlarning eskiz dasturida (LED) Sketch dasturi LEDni yoqishning
bir necha usullari mavjud, quyida Active HIGH bilan eskiz dasturi tushuntiriladi.
Eskiz dasturining birinchi usuli:
// LED chiroq Arduino UNO yordamida ishlaydi
// LEDni faol ravishda yoqing.
void setup()
{
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
// menjadikan PIN 0, 1, 2, 3, dan 4 sebagai OUTPUT
}
void loop()
{
//menyala secara bergilir
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
delay(1000);
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
delay(1000);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
delay(1000);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
delay(1000);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
delay(1000);
}
|