Al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti



Yüklə 0,75 Mb.
tarix16.12.2023
ölçüsü0,75 Mb.
#182713
anvar lot 5 6


O‘ZBEKISTON RESPUBLIKASI RAQAMLI TEXNOLOGIYALAR VAZIRLIGI MUHAMMAD
AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
Kompyuter injiniringi fakulteti
IoT texnologiyalari fanidan
5-TOPSHIRIQ

Bajardi: 221-21 guruh talabasi :


Abdusattorov Anvar
Tekshirdi: Ma‘mirov Xudoyberdi

TOSHKENT 2023

5-amaliy topshiriq Tinkercad.com virtual laboratoriya va Arduino kit yordamida Ultrsonic sensor HC-SR04 ni ishlatish.


Dastur kodi

/*
Abdusattorov Anvar
*/
#include // includes the LiquidCrystal Library
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
const int trigPin = 9;
const int echoPin = 10;
long duration;
int distanceCm, distanceInch;
void setup() {
lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distanceCm= duration*0.034/2;
distanceInch = duration*0.0133/2;
lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("Distance: "); // Prints string "Distance" on the LCD
lcd.print(distanceCm); // Prints the distance value from the sensor
lcd.print(" cm");
delay(10);
lcd.setCursor(0,1);
lcd.print("Distance: ");
lcd.print(distanceInch);
lcd.print(" inch");
delay(10);
}


6-amaliy topshiriq.
Tinkercad.com virtual laboratoriya va Arduino Uno dan foydalanib Temperatura sensorini ishlatish va natijani Serial monitorga va displeyga chiqarish.






Dastur kodi:
/*
Abdusattorov Anvar
*/
#include

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;


LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

float celsius;


int temp = A1;
void setup(){
pinMode(temp,INPUT);
}
void loop(){
celsius = analogRead(temp)*0.004882814;
celsius = (celsius - 0.5) * 100.0;
lcd.setCursor(0,1);
lcd.print("Temp: ");
lcd.print(celsius);
lcd.print(" C");
delay(1000);
lcd.clear();
}
Yüklə 0,75 Mb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin