2025 Muallif: John Day | [email protected]. Oxirgi o'zgartirilgan: 2025-01-13 06:58
Oldingi qo'llanmada men RGB halqa neo piksellari yordamida potentsiometr ko'rsatkichini ko'rsatdim. Buni "Potentsio indikatori RGB neopikselidan foydalanadi" maqolasida ko'rishingiz mumkin.
Va bugun men MAX7219 LED metrik displeyi yordamida potensator ko'rsatkichini ko'rsataman.
Buni amalga oshirish uchun quyidagi amallarni bajaring.
1 -qadam: kerakli komponentlar
Kerakli komponentlar:
- Arduino nano
- Potentsiometr
- Max 7219 LED matritsali displey
- Jumper simlari
- Loyiha kengashi
- USB mini
- noutbuk
Majburiy kutubxona
LedControl
2 -qadam: sxema
Komponentlarni yig'ish uchun yuqoridagi sxematik rasmga qarang, shuningdek quyidagi ma'lumotlarni ko'rishingiz mumkin:
Arduino - Led va potentsial
+5V ==> VCC va 3. Potentio
GND ==> GND & 1. Potentsial
D6 ==> DataIn
D7 ==> CLK
D8 ==> CS / Yuklash
3 -qadam: dasturlash
Aytish uchun quyidagi kodni ishlating:
#"LedControl.h" ni qo'shing
/*
Endi biz bilan ishlash uchun LedControl kerak. ***** Bu pin raqamlari sizning apparatingiz bilan ishlamasligi mumkin ***** 6 -pin DataIn -ga ulangan 7 -pin CLK -ga ulangan 8 -LOADga ulangan Bizda faqat bitta MAX72XX bor. */
LedControl lc = LedControl (6, 7, 8, 1);
imzosiz uzoq kechikish = 100;
bo'sh o'rnatish () {
lc.shutdown (0, noto'g'ri); lc.setIntensity (0, 8); lc.clearDisplay (0); } void loop () {int val = analogRead (A0); val = xarita (val, 0, 1023, 0, 8);
agar (val == 1)
{
lc.setRow (0, 0, B10000000);
}
agar (val == 2)
{lc.setRow (0, 0, B10000000); lc.setRow (0, 1, B10000000); } agar (val == 3) {
lc.setRow (0, 0, B10000000);
lc.setRow (0, 1, B10000000); lc.setRow (0, 2, B10000000); } agar (val == 4) {
lc.setRow (0, 0, B10000000);
lc.setRow (0, 1, B10000000); lc.setRow (0, 2, B10000000); lc.setRow (0, 3, B10000000); } agar (val == 5) {
lc.setRow (0, 0, B10000000);
lc.setRow (0, 1, B10000000); lc.setRow (0, 2, B10000000); lc.setRow (0, 3, B10000000); lc.setRow (0, 4, B10000000); } agar (val == 6) {lc.setRow (0, 0, B10000000); lc.setRow (0, 1, B10000000); lc.setRow (0, 2, B10000000); lc.setRow (0, 3, B10000000); lc.setRow (0, 4, B10000000); lc.setRow (0, 5, B10000000); } agar (val == 7) {lc.setRow (0, 0, B10000000); lc.setRow (0, 1, B10000000); lc.setRow (0, 2, B10000000); lc.setRow (0, 3, B10000000); lc.setRow (0, 4, B10000000); lc.setRow (0, 5, B10000000); lc.setRow (0, 6, B10000000); } agar (val == 8) {lc.setRow (0, 0, B10000000); lc.setRow (0, 1, B10000000); lc.setRow (0, 2, B10000000); lc.setRow (0, 3, B10000000); lc.setRow (0, 4, B10000000); lc.setRow (0, 5, B10000000); lc.setRow (0, 6, B10000000); lc.setRow (0, 7, B10000000); } lc.clearDisplay (0); }
4 -qadam: Natija
Dasturlashtirilgandan so'ng, natijalar shunday bo'ladi.
Agar potentio o'ngga burilsa, jonli LEDlar tobora burilishlar soniga ergashadi.
Agar qozon chapga burilgan bo'lsa, aylanish potentsialidan keyin jonli LED kamroq bo'ladi.