O‘ZBEKISTON RESPUBLIKASI RAQAMLI TEXNOLOGIYALAR VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
O’rnatilgan tizimlar
3-topshiriq
Guruh raqami: 850-20
Ibragimov Elchinbek
Toshkent-2023
1. Rele. Releni tranzistor orqali boshqarish.
void setup()
{
pinMode(7, OUTPUT);
}
void loop()
{
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(7, LOW);
delay(1000);
}
2. Fotoqarshilik. Yorug‘lik diodlarini yoqish yoki o‘chirish orqali yorug‘lik darajasiga ishlov berish.
int sensorValue = 0;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
pinMode(9, OUTPUT);
}
void loop()
{
// read the value from the sensor
sensorValue = analogRead(A0);
// print the sensor reading so you know its range
Serial.println(sensorValue);
// map the sensor reading to a range for the LED
analogWrite(9, map(sensorValue, 0, 1023, 0, 255));
delay(100); // Wait for 100 millisecond(s)
}
3. LM335 xarorat datchigi (uzuluksiz). Ishlash tamoili, ishlatishga misol.
char degree=176;
void setup()
{
pinMode(A0,INPUT);
Serial.begin(9600);
}
void loop()
{
int temp = analogRead(A0);
float voltage = (temp*5)/1024;
float milivolt = voltage*1000;
float celsius = (milivolt-500)/10;
float fahrenheit = (celsius*9/5)+32;
Serial.print("10 bit number : " );
Serial.println(temp);
Serial.print("voltage : " );
Serial.print(voltage);
Serial.print("milivolt : " );
Serial.print(milivolt);
Serial.println("V");
Serial.print("celsius : " );
Serial.print(celsius);
Serial.println(degree);
Serial.print("fahrenheit : " );
Serial.print(fahrenheit);
delay(1000);
}
4. LCD1602 indikatori. Ulanish tamoili, unga axborotni Arduinoda foydalanib chiqarish.
#include
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
lcd.begin(16, 2);
}
void loop() {
lcd.setCursor(8,0);
hourPrint();
lcd.setCursor(11,0);
minutePrint();
lcd.setCursor(14,0);
secondPrint();
}
void hourPrint(){
int h = (millis()/360000)%12;
if(h<10){
lcd.print("0");
lcd.print(h);
}
else{lcd.print(h); }
lcd.print(":");
}
void minutePrint(){
int m = (millis()/6000)%60;
if(m<10){
lcd.print("0");
lcd.print(m);
}
else{ lcd.print(m); }
lcd.print(":");
}
void secondPrint(){
int s = (millis()/100)%60;
if(s<10){
lcd.print("0");
lcd.print(s);}
else{ lcd.print(s);} }
5. Simsiz aloqa tarmoqlari orqali ma’lumotlarni uzatish va boshqarish
void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH);
delay(2000);
digitalWrite(13, LOW);
delay(2000);
}
Dostları ilə paylaş: |