|
O‘rnatilgan tizimlari fanidan 6-amaliy ish topshirig‘i mavzu: Avtomobillar uchun smart avtoturargoh loyihalash
|
Sana | 21.05.2024 | Hajmi | 316,39 Kb. | | #247914 |
O‘ZBEKISTON RESPUBLIKASI
RAQAMLI TEXNOLOGIYALAR VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
O‘rnatilgan tizimlari fanidan
6-AMALIY ISH TOPSHIRIG‘I
Mavzu: Avtomobillar uchun smart avtoturargoh loyihalash. (Servo mator, masofa va harakat sensorlari)
Bajardi: 411-21 guruh talabasi
Sharipov Dilshod
Tekshirdi: Azimova U.
TOSHKENT – 2024
// C++ code
//
int ButtonValue = 0;
int i = 0;
int j = 0;
int k = 0;
int m = 0;
int unnamed = 0;
int n = 0;
int timer = 0;
int o = 0;
int p = 0;
void setup()
{
pinMode(2, INPUT);
pinMode(12, OUTPUT);
pinMode(8, OUTPUT);
}
void loop()
{
ButtonValue = digitalRead(2);
if (ButtonValue == LOW) {
digitalWrite(12, HIGH);
for (timer = 1; timer <= 10; timer += 1) {
delay(1000); // Wait for 1000 millisecond(s)
if (timer == 10) {
digitalWrite(8, HIGH);
}
}
}
if (ButtonValue == HIGH) {
digitalWrite(12, LOW);
digitalWrite(8, LOW);
}
}
https://www.tinkercad.com/things/cAiCfEc3M2B-copy-of-fridge-light-and-warning-sound/editel?sharecode=6lwNx8omd-evaxz66X2UrfxfsmD8YnX58q0EzBmblhw
Code
#include
#define trig 9
#define echo 8
#define ovoz 7
int servoPin = 11;
int holat = 2;
Servo servo1;
void setup() {
pinMode(holat, INPUT);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
pinMode(ovoz, OUTPUT);
servo1.attach(servoPin);
Serial.begin(9600);
}
void loop() {
digitalWrite(trig, HIGH);
delay(10);
digitalWrite(trig, LOW);
int harakat = digitalRead(holat);
int holat = pulseIn(echo, HIGH);
int masofa = holat*0.0343/2;
if(harakat == HIGH) {
if(masofa == 400) {
servo1.write(180);
} else {
servo1.write(0);
}
} else {
servo1.write(0);
}
Serial.println(masofa);
}
Json
{
"version": 1,
"author": "Dilshod Jurayev",
"editor": "wokwi",
"parts": [
{ "type": "wokwi-arduino-uno", "id": "uno", "top": 94.35, "left": 18.84, "attrs": {} },
{
"type": "wokwi-hc-sr04",
"id": "ultrasonic1",
"top": -53.57,
"left": 72.61,
"attrs": { "distance": "302" }
},
{
"type": "wokwi-servo",
"id": "servo1",
"top": 151.6,
"left": -182.4,
"rotate": 180,
"attrs": {}
},
{ "type": "wokwi-pir-motion-sensor", "id": "pir1", "top": -34.4, "left": 424.62, "attrs": {} }
],
"connections": [
[ "ultrasonic1:VCC", "uno:5V", "red", [ "v-0.28", "h-175.91", "v281.67", "h207.08" ] ],
[ "uno:GND.3", "ultrasonic1:GND", "black", [ "v32.96", "h117.64", "v-233.41" ] ],
[ "ultrasonic1:TRIG", "uno:9", "green", [ "v19.9", "h28.2" ] ],
[ "ultrasonic1:ECHO", "uno:8", "green", [ "v12.88", "h15.56" ] ],
[ "servo1:GND", "uno:GND.3", "black", [ "h12.4", "v114.4", "h201.6" ] ],
[ "servo1:PWM", "uno:11", "green", [ "h2.8", "v-145", "h172.8" ] ],
[ "servo1:V+", "uno:VIN", "green", [ "h2.8", "v123.9", "h220.8" ] ],
[ "pir1:VCC", "uno:5V", "red", [ "v288", "h-297.6" ] ],
[ "pir1:OUT", "uno:2", "green", [ "v9.6", "h-201.74" ] ],
[ "pir1:GND", "uno:GND.1", "black", [ "v19.2", "h-345.86" ] ]
],
"dependencies": {}
}
|
| |