Ushbu postda siz Arduino svetoforini boshqaruvchini qanday yasash haqida bilib olasiz. Ushbu svetofor boshqaruvchisi transport oqimini boshqarish uchun ishlatiladi. Yo'l harakati to'siqlari yoki baxtsiz hodisalarning oldini olish uchun ular tirbandlik yuqori bo'lgan joylarda qo'llanilishi mumkin.
Ushbu loyihaning asosiy qismi Arduino bo'lib, u transport vositalarini boshqarish uchun LEDlarni va ularning vaqtlarini boshqaradi.
Men ham Arduino yordamida zichlikka asoslangan svetofor boshqaruvchisini yaratdim . Buni ko'rib chiqishni unutmang.
Maxsus loyihalar uchun meni https://www.freelancer.com/u/Muhammadaqibdutt orqali ishga oling.
Arduino svetofor boshqaruvchisining ishlashi
Ushbu loyiha sizga svetofor boshqaruvchisi qanday ishlashi haqida tasavvur berish uchun qilingan. Bu real vaqtda svetofor boshqaruvchisi emas.
Shunday qilib, ishga tushirilganda 1-signalning yashil chirog'i va boshqa signallardagi qizil chiroqlar yonib, 1-signaldagi transport vositalariga o'tish uchun vaqt beradi.
5 soniyadan so'ng, 1-signaldagi sariq chiroq yonadi va 1-signaldagi qizil chiroq yonish arafasida ekanligini bildiradi, shuningdek, 2-signaldagi transport vositalariga yashil chiroq yonish arafasida ekanligini ko'rsatadi. .
Shunday qilib, 2 soniyadan keyin 1-signaldagi qizil chiroq yonadi va signaldagi yashil chiroq yonadi, ya'ni 1-signaldagi transport vositalari to'xtashi kerak va 2-signaldagi transport vositalari harakatlanishi mumkin.
Xuddi shunday svetofor boshqaruvchisi signal 3, signal 4 uchun ishlaydi va tizim aylanishda davom etadi.
Arduino svetofor boshqaruvchisi uchun zarur komponentlar
Arduino svetofor boshqaruvchisi uchun sizga kerak bo'ladigan komponentlar quyidagilardir
Arduino Mega 2560
Qizil LEDlar (4 dona)
Sariq LEDlar (4 dona)
Yashil LEDlar (4 dona)
220 ohm rezistorlar (12 dona)
O'tkazgich kabellari
Non taxtalari
Arduino svetoforini boshqarish moslamasining sxemasi
Ushbu loyihada jami 12 ta LED ishlatilgan. Har bir signalga 220 ohm rezistorlar orqali ulangan 3 ta LED (qizil, sariq va yashil) mavjud.
Rezistorlar LEDlar orqali o'tadigan oqimni cheklash uchun ishlatiladi. Agar siz rezistorlardan foydalanmasangiz, LEDlar haddan tashqari oqim tufayli yonib ketishi mumkin.
Ko'proq o'qish:
Arduino bilan LED interfeysi
Kod tushuntirish
Avvalo, biz signal pinlari uchun to'rtta massivni ishga tushirdik va LEDlarni ulagan pinlarni aniqladik.
int signal1[] = {23, 25, 27};
int signal2[] = {46, 48, 50};
int signal3[] = {13, 12, 11};
int signal4[] = {10, 9, 8};
int redDelay = 5000;
int yellowDelay = 2000;
void setup() {
// Declaring all the LED's as output
for (int i = 0; i < 3; i++) {
pinMode(signal1[i], OUTPUT);
pinMode(signal2[i], OUTPUT);
pinMode(signal3[i], OUTPUT);
pinMode(signal4[i], OUTPUT);
}
}
void loop() {
// Making Green LED at signal 1 and red LED's at other signal HIGH
digitalWrite(signal1[2], HIGH);
digitalWrite(signal1[0], LOW);
digitalWrite(signal2[0], HIGH);
digitalWrite(signal3[0], HIGH);
digitalWrite(signal4[0], HIGH);
delay(redDelay);
// Making Green LED at signal 1 LOW and making yellow LED at signal 1 HIGH for 2 seconds
digitalWrite(signal1[1], HIGH);
digitalWrite(signal1[2], LOW);
delay(yellowDelay);
digitalWrite(signal1[1], LOW);
// Making Green LED at signal 2 and red LED's at other signal HIGH
digitalWrite(signal1[0], HIGH);
digitalWrite(signal2[2], HIGH);
digitalWrite(signal2[0], LOW);
digitalWrite(signal3[0], HIGH);
digitalWrite(signal4[0], HIGH);
delay(redDelay);
// Making Green LED at signal 2 LOW and making yellow LED at signal 2 HIGH for 2 seconds
digitalWrite(signal2[1], HIGH);
digitalWrite(signal2[2], LOW);
delay(yellowDelay);
digitalWrite(signal2[1], LOW);
// Making Green LED at signal 3 and red LED's at other signal HIGH
digitalWrite(signal1[0], HIGH);
digitalWrite(signal2[0], HIGH);
digitalWrite(signal3[2], HIGH);
digitalWrite(signal3[0], LOW);
digitalWrite(signal4[0], HIGH);
delay(redDelay);
// Making Green LED at signal 3 LOW and making yellow LED at signal 3 HIGH for 2 seconds
digitalWrite(signal3[1], HIGH);
digitalWrite(signal3[2], LOW);
delay(yellowDelay);
digitalWrite(signal3[1], LOW);
// Making Green LED at signal 4 and red LED's at other signal HIGH
digitalWrite(signal1[0], HIGH);
digitalWrite(signal2[0], HIGH);
digitalWrite(signal3[0], HIGH);
digitalWrite(signal4[2], HIGH);
digitalWrite(signal4[0], LOW);
delay(redDelay);
// Making Green LED at signal 4 LOW and making yellow LED at signal 4 HIGH for 2 seconds
digitalWrite(signal4[1], HIGH);
digitalWrite(signal4[2], LOW);
delay(yellowDelay);
digitalWrite(signal4[1], LOW);
}
Do'stlaringiz bilan baham: |