Mundarija:
2025 Muallif: John Day | [email protected]. Oxirgi o'zgartirilgan: 2025-01-13 06:58
O'quv xonasi uchun taymerni yaratish bo'yicha ko'rsatmalar.
1 -qadam: o'zaro video
drive.google.com/file/d/12z5zQR52AXILX2AGb3EplfbmZWANZiCl/view?usp=drivesdk
2 -qadam: Muammo haqida bayonot
Ko'pincha, o'quv xonalari har doim olinadi. Bu odamlarning xonada kerak bo'lgandan ko'ra ko'proq vaqt qolishni yaxshi ko'rishi tufayli sodir bo'ladi. Biz taymerni ishlab chiqdik, u har bir kishiga jami 2 soat vaqt ajratadi va xonani keyingi guruh bo'lishini so'rash imkoniyatini kutadi. Neopikselda RGB -dan foydalanish qolgan vaqtni bildiradi.
3 -qadam: Bu qanday ishlashini ko'rib chiqish
Taymer lazer kesgich bilan kesilgan qismlardan, 3 tugmachadan, 1 LEDdan, 1 potensiometrdan iborat.
Neopiksel va potansiometr NodeMCU ga ulangan. NodeMCU, dumaloq Neopixel tasmasida yoritilgan LEDlar miqdorini o'zgartirish uchun potansiyometr qanchalik uzoqqa burilganligini qayta tartibga solish uchun dasturlashtirilgan. "So'rov" tugmasi "Ishga tushirish", "To'xtatish" va "Vaqtni sozlash" funktsiyasini to'xtatadi. Xona ichidagi taymerdagi LEDlarning rangi qutining yon tomonida yonib turgan LEDning rangi bilan bir xil. Qutining yon tomonidagi neopixel binoning foyesida qaysi xonani olish va qancha vaqt qolganini bilish uchun displeyni ifodalaydi. Har bir xona uchun 2 ta LED o'rnatilgan, bitta LED xona olinganligini bildiradi, ikkinchisi esa taymerda LEDlarning rangini aks ettiradi (yashil vaqt ko'proq, keyin sariq, keyin qizil vaqt kamroq).
4 -qadam: Materiallar va asboblar ro'yxati
-Tiniq akril
-MicroUSB kabeli
www.digikey.com/product-detail/uz/stewart-…
-Non paneli
www.amazon.com/gp/product/B01EV6LJ7G/ref=o…
-Potentsiometr
www.alliedelec.com/honeywell-380c32500/701…
-3 tugma
www.digikey.com/product-detail/uz/te-conne…
-NodeMCU
www.amazon.com/gp/product/B07CB4P2XY/ref=o…
- 2 ta neopikselli chiziqlar
www.amazon.com/Lighting-Modules-NeoPixel-W…
-Rezistorlar
www.digikey.com/product-detail/en/te-conne…
- Simlar
www.digikey.com/product-detail/en/sparkfun…
-1 ta LED
www.mouser.com/ProductDetail/Cree-Inc/C512…
-Issiq yopishtiruvchi qurol
www.walmart.com/ip/AdTech-Hi-Temp-Mini-Hot…
-yopishqoq Velcro chiziqlar
www.amazon.com/VELCRO-Brand-90076-Fastener…
5 -qadam: Qurilish dasturini taxtadan boshlang
A0 - potentsiometrning o'rta pimi
Vin Neopixel uzukni yoqadi
Potentsiometrning bir tomoniga 3v3
NodeMCU -da barcha asoslar
D1 tugmachasini so'rash
LEDni so'rash uchun D2
Boshlash tugmasi uchun D3
To'xtatish tugmasi uchun D4
D5 halqadagi Neopixel kirish qarshiligiga
Neopixel kirish chizig'iga qarshilik uchun D6
6 -qadam: Kodni ishga tushirish
Bu sizning loyihangiz hozirgacha ishlayotganiga ishonch hosil qilish uchun kod. Taymer Neopixel halqasidagi har bir LED uchun atigi bir necha soniya bo'lishi kerak. Siz bilasizki, u hozirgacha ishlaydi. Vaqt ajratish uchun siz o'zgartirishingiz kerak bo'lgan bayonotlarni har safar "Vaqtni o'zgartiring" deb qo'yaman.
Kodni sinab ko'rish:
vaqtni import qilish
import vaqti
ADC mashina importidan
import mashinasi
neopixel import qilish
adc = ADC (0)
pin = machine. Pin (14, machine. Pin. OUT)
np = neopixel. NeoPixel (pin, 12)
pin2 = mashina. Pin (12, mashina. Pin. OUT)
np2 = neopixel. NeoPixel (pin2, 8)
l1 = mashina. Pin (4, mashina. Pin. OUT)
b1 = machine. Pin (5, machine. Pin. IN, machine. Pin. PULL_UP)
b3 = machine. Pin (2, machine. Pin. IN, machine. Pin. PULL_UP)
b2 = machine. Pin (0, machine. Pin. IN, machine. Pin. PULL_UP)
l1.qiymat (0)
def tglled (): # "so'rov" LED funksiyasini almashtirish
agar l1.value () == 0:
l1.qiymat (1)
boshqa:
l1.qiymat (0)
x = 0
b1temp1 = 0
b1temp2 = 0
t = 0
b2temp1 = 0
b2temp2 = 0
b3temp1 = 0
b3temp2 = 0
s = 0
rost bo'lsa:
# Bu "so'rov" LEDini almashtiradigan tugma
b1temp2 = b1.value ()
agar b1temp2 emas, balki b1temp2:
tglled ()
uyqu (0,05)
b1temp1 = b1temp2
# Bu tarmoq
np2 [0] = np [11]
agar l1.value () == 1:
np2 [1] = (30, 0, 0)
boshqa:
np2 [1] = (0, 0, 30)
np2.write ()
# Bu erda biz qancha vaqt kerakligini tanlaymiz
agar t == 0 bo'lsa:
i uchun (-1, 12):
agar (l1.value () == 0):
agar (adc.read ()> = (85.34 * (i+1))):
np = (0, 0, 0)
np [11] = (0, 0, 30)
s = (i + 1)
boshqa:
np = (0, 0, 30)
np.write ()
boshqa:
np = (0, 0, 0)
np.write ()
# Bu taymerni ishga tushirish tugmasi
agar (l1.value () == 0) va (t == 0):
b2temp2 = b2.value ()
agar b2temp2 emas, b2temp2 bo'lsa:
x += 1
t += (s * 100)
uyqu (0,05)
b2temp1 = b2temp2
# Bu tugma taymerni tugatadi
agar (l1.value () == 0):
b3temp2 = b3.value ()
b3temp2 emas, balki b3temp2 bo'lsa:
x = 0
t = 0
uyqu (0,05)
b3temp1 = b3temp2
# Bu taymer
agar x> 0 bo'lsa:
t += 1
agar (t> 0) va (t <= 100): #Vaqtni o'zgartirish
np [0] = (5, 30, 0)
np [1] = (5, 30, 0)
np [2] = (5, 30, 0)
np [3] = (5, 30, 0)
np [4] = (5, 30, 0)
np [5] = (5, 30, 0)
np [6] = (5, 30, 0)
np [7] = (5, 30, 0)
np [8] = (5, 30, 0)
np [9] = (5, 30, 0)
np [10] = (5, 30, 0)
np [11] = (5, 30, 0)
np.write ()
agar (t> 100) va (t <= 200): #Vaqtni o'zgartirish
np [0] = (0, 0, 0)
np [1] = (10, 30, 0)
np [2] = (10, 30, 0)
np [3] = (10, 30, 0)
np [4] = (10, 30, 0)
np [5] = (10, 30, 0)
np [6] = (10, 30, 0)
np [7] = (10, 30, 0)
np [8] = (10, 30, 0)
np [9] = (10, 30, 0)
np [10] = (10, 30, 0)
np [11] = (10, 30, 0)
np.write ()
agar (t> 200) va (t <= 300): #Vaqtni o'zgartirish
np [0] = (0, 0, 0)
np [1] = (0, 0, 0)
np [2] = (15, 30, 0)
np [3] = (15, 30, 0)
np [4] = (15, 30, 0)
np [5] = (15, 30, 0)
np [6] = (15, 30, 0)
np [7] = (15, 30, 0)
np [8] = (15, 30, 0)
np [9] = (15, 30, 0)
np [10] = (15, 30, 0)
np [11] = (15, 30, 0)
np.write ()
agar (t> 300) va (t <= 400): #Vaqtni o'zgartirish
np [0] = (0, 0, 0)
np [1] = (0, 0, 0)
np [2] = (0, 0, 0)
np [3] = (20, 30, 0)
np [4] = (20, 30, 0)
np [5] = (20, 30, 0)
np [6] = (20, 30, 0)
np [7] = (20, 30, 0)
np [8] = (20, 30, 0)
np [9] = (20, 30, 0)
np [10] = (20, 30, 0)
np [11] = (20, 30, 0)
np.write ()
agar (t> 400) va (t <= 500): #Vaqtni o'zgartirish
np [0] = (0, 0, 0)
np [1] = (0, 0, 0)
np [2] = (0, 0, 0)
np [3] = (0, 0, 0)
np [4] = (25, 30, 0)
np [5] = (25, 30, 0)
np [6] = (25, 30, 0)
np [7] = (25, 30, 0)
np [8] = (25, 30, 0)
np [9] = (25, 30, 0)
np [10] = (25, 30, 0)
np [11] = (25, 30, 0)
np.write ()
agar (t> 500) va (t <= 600): #Vaqtni o'zgartirish
np [0] = (0, 0, 0)
np [1] = (0, 0, 0)
np [2] = (0, 0, 0)
np [3] = (0, 0, 0)
np [4] = (0, 0, 0)
np [5] = (30, 30, 0)
np [6] = (30, 30, 0)
np [7] = (30, 30, 0)
np [8] = (30, 30, 0)
np [9] = (30, 30, 0)
np [10] = (30, 30, 0)
np [11] = (30, 30, 0)
np.write ()
agar (t> 600) va (t <= 700): #Vaqtni o'zgartirish
np [0] = (0, 0, 0)
np [1] = (0, 0, 0)
np [2] = (0, 0, 0)
np [3] = (0, 0, 0)
np [4] = (0, 0, 0)
np [5] = (0, 0, 0)
np [6] = (30, 25, 0)
np [7] = (30, 25, 0)
np [8] = (30, 25, 0)
np [9] = (30, 25, 0)
np [10] = (30, 25, 0)
np [11] = (30, 25, 0)
np.write ()
agar (t> 700) va (t <= 800): #Vaqtni o'zgartirish
np [0] = (0, 0, 0)
np [1] = (0, 0, 0)
np [2] = (0, 0, 0)
np [3] = (0, 0, 0)
np [4] = (0, 0, 0)
np [5] = (0, 0, 0)
np [6] = (0, 0, 0)
np [7] = (30, 20, 0)
np [8] = (30, 20, 0)
np [9] = (30, 20, 0)
np [10] = (30, 20, 0)
np [11] = (30, 20, 0)
np.write ()
agar (t> 800) va (t <= 900): #Vaqtni o'zgartirish
np [0] = (0, 0, 0)
np [1] = (0, 0, 0)
np [2] = (0, 0, 0)
np [3] = (0, 0, 0)
np [4] = (0, 0, 0)
np [5] = (0, 0, 0)
np [6] = (0, 0, 0)
np [7] = (0, 0, 0)
np [8] = (30, 15, 0)
np [9] = (30, 15, 0)
np [10] = (30, 15, 0)
np [11] = (30, 15, 0)
np.write ()
agar (t> 900) va (t <= 1000): #Vaqtni o'zgartirish
np [0] = (0, 0, 0)
np [1] = (0, 0, 0)
np [2] = (0, 0, 0)
np [3] = (0, 0, 0)
np [4] = (0, 0, 0)
np [5] = (0, 0, 0)
np [6] = (0, 0, 0)
np [7] = (0, 0, 0)
np [8] = (0, 0, 0)
np [9] = (30, 10, 0)
np [10] = (30, 10, 0)
np [11] = (30, 10, 0)
np.write ()
agar (t> 1000) va (t <= 1100): #Vaqtni o'zgartirish
np [0] = (0, 0, 0)
np [1] = (0, 0, 0)
np [2] = (0, 0, 0)
np [3] = (0, 0, 0)
np [4] = (0, 0, 0)
np [5] = (0, 0, 0)
np [6] = (0, 0, 0)
np [7] = (0, 0, 0)
np [8] = (0, 0, 0)
np [9] = (0, 0, 0)
np [10] = (30, 5, 0)
np [11] = (30, 5, 0)
np.write ()
agar (t> 1100) va (t <= 1200): #Vaqtni o'zgartirish
np [0] = (0, 0, 0)
np [1] = (0, 0, 0)
np [2] = (0, 0, 0)
np [3] = (0, 0, 0)
np [4] = (0, 0, 0)
np [5] = (0, 0, 0)
np [6] = (0, 0, 0)
np [7] = (0, 0, 0)
np [8] = (0, 0, 0)
np [9] = (0, 0, 0)
np [10] = (0, 0, 0)
np [11] = (30, 0, 0)
np.write ()
agar t> = 1300: #Vaqtni o'zgartiring
t = 0
x = 0
7 -qadam: teginishni tugatish
Endi, bu erga borganingizdan so'ng, siz NodeMCU -ga ish kodini yuklashingiz va uning barcha qismlari non paneliga ulangan bo'lishingiz kerak. Agar siz kodni sinab ko'rsangiz va tashqi qismingiz, ya'ni lazer bilan kesilgan bo'laklarni kesib qo'ysangiz, endi simlarni NodeMCU ga lehimlashingiz mumkin. Lehimlash ixtiyoriy, lekin uni korpus uchun xavfsizroq va kichikroq qilib qo'yishi mumkin. Mana biz tayyorlagan lazer qismlari.