MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI
UNIVERSITETI
Telekomunikatsiya texnologiyalari fakulteti
417-20 guruhi talabasi Rustamov Fayzulloning
O’rnatilgan tizimlar fanidan
3-amaliy ishi
Tekshirdi: Nurmurodov Javohir
1-TOPSHIRIQ
Rele. Releni tranzistor orqali boshqarish.
Kodi:
const int trig = 10;
const int echo = 9;
int rele = 5;
int sure = 0;
int mesafe = 0;
void setup()
{
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
pinMode(rele, OUTPUT);
}
void loop()
{
digitalWrite(trig, HIGH);
delayMicroseconds(2);
digitalWrite(trig, LOW);
sure=pulseIn(echo,HIGH);
mesafe=(sure/2)/29.1;
Serial.print("Mesafe");
Serial.print(mesafe);
Serial.println("cm");
delay(2);
if (mesafe<50)
{digitalWrite(rele,HIGH);}
else {digitalWrite(rele,LOW);}
}
2--TOPSHIRIQ
Fotoqarshilik. Yorug‘lik diodlarini yoqish yoki o‘chirish orqali yorug‘lik darajasiga ishlov berish.
Kodi:
void setup()
{
pinMode(A0, INPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int signal=analogRead(A0);
if (signal<=250 && signal>=200)
{
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
if (signal<=350 && signal>=300)
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
if (signal<=450 && signal>=400)
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
if (signal<=550 && signal>=500)
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
if (signal<=650 && signal>=600)
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
}
Serial.println(signal);
}
Dostları ilə paylaş: |