IoT texnologiyalari 3-Amaliy Ish Bajardi


Download 25.7 Kb.
Sana31.01.2024
Hajmi25.7 Kb.
#1819453
Bog'liq
rayhona lot 3 4


OʻZBEKISTON RESPUBLIKASI AXBOROT
TEXNOLOGIYALARI VA
KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI



IoT texnologiyalari
3-Amaliy Ish
Bajardi: Vahobjonova Rayhona
Tekshirdi: Ma‘mirov Xudoyberdi


Toshkent 2023
3 - amaliy topshiriq

Tinkercad.com virtual laboratoriya yordamida PIR motion sensor ni ishlatish, Arduino kit yordamida PIR sensor harakat sezganda LED ni yonsin, harakat sezmaganda o‘chsin











int led = 12;
int sensor = 2;
int state = LOW;
int val = 0;
void setup() {
pinMode(led, OUTPUT);
pinMode(sensor, INPUT);
Serial.begin(9600);
}
void loop(){
val = digitalRead(sensor);
if (val == HIGH) {
digitalWrite(led, HIGH);
delay(100);
if (state == LOW) {
Serial.println("Motion detected!");
state = HIGH;
}
}
else {
digitalWrite(led, LOW);
delay(200);
if (state == HIGH){
Serial.println("Motion stopped!");
state = LOW;
}
}}
4-amaliy ish
tinkercad.com virtual laboratoriya va arduino kit yordamida yetti segmentli indikatorni ishlatish.



Dastur kodi:
byte pins[8] = {2,3,4,6,7,8,9};
int duration = 500;
byte num0 = 0x3F;
byte num1 = 0x0C;
byte num2 = 0x5B;
byte num3 = 0x5E;
byte num4 = 0x6C;
byte num5 = 0x76;
byte num6 = 0x77;
byte num7 = 0x1C;
byte num8 = 0x7F;
byte num9 = 0x7E;
void printN(byte _digit) {
for (int i = 0; i < 8; i++) {
digitalWrite(pins[i], bitRead(_digit, i ));
}
}
void setup() {
Serial.begin(9600);
for(int i = 0; i <= 9; i++) {
pinMode(pins[i], OUTPUT);
}
}
void loop() {
printN(num0); delay(duration);
printN(num1); delay(duration);
printN(num2); delay(duration);
printN(num3); delay(duration);
printN(num4); delay(duration);
printN(num5); delay(duration);
printN(num6); delay(duration);
printN(num7); delay(duration);
printN(num8); delay(duration);
printN(num9); delay(duration);
}
Download 25.7 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling