2025 Muallif: John Day | [email protected]. Oxirgi o'zgartirilgan: 2025-01-13 06:58
Men orqa hovlim uchun qandaydir interaktiv hovli chiroqlarini qurmoqchi edim. Gap shundaki, kimdir bir tomonga yurganida, u siz yurgan tomonga animatsiyani qo'yadi. Men Dollar General -dan 1,00 dollarlik quyosh chiroqlaridan boshladim
1 -qadam: Chiroqlarni o'chiring
Birinchi qadam, chiroqlarni o'chirish, yanada qiziqarli narsalarga yo'l ochish edi. Men asl chiroqni va batareyani kesishdan boshladim. Bu qismlarni saqlaganingizga ishonch hosil qiling, chunki ular boshqa loyihada foydali bo'ladi, men quyosh nuri ostidagi xrom gumbazni olib tashladim va fotosuratda ko'rinib turganidek tepaga yopishtirdim.
2 -qadam: Yaxshi chiroqlarni o'rnatish
led uchun men suv o'tkazmaydigan ws2811b ishlatardim, bu erda
www.ebay.com/itm/50-X-12mm-LED-Module-RGB-…
Men dastlab PIR sensorlarini quyosh chiroqlariga joylashtirishni rejalashtirgandim. Lekin bu juda muammoli bo'lib chiqdi, chunki sensor asosan plastmassadan o'tmagan. u UV filtrlash xususiyatiga ega bo'lishi kerak. shuning uchun men shunga o'xshash narsani tanladim
www.thingiverse.com/thing:2590216
3 -qadam: kodlash
Agar siz chiroqni sensordan foydalanmasligingizni yoki doimo ishlashini xohlasangiz, "bayroq holatini o'zgartirish" deb yozilgan joyni qidiring va uni 1 yoki 0 ga efirga qo'ying, men buni o'zim uchun to'ldirganimda ko'proq rasm qo'shaman. bu hali ham davom etayotgan ish, lekin menimcha, darhol baham ko'rmaslik juda to'g'ri. qaraganingiz uchun rahmat
bo'sh o'rnatish () {
// bir marta ishga tushirish uchun sozlash kodini bu erga qo'ying: FastLED.addLeds (leds, NUM_LEDS); Serial.begin (9600); pinMod (tugmaPin1, Kirish); pinMod (tugmaPin2, Kirish); }
void loop () {
Serial.println (FlagState);
if (FlagState == 0) {ForwardLeds (); } if (FlagState == 1) {RevLeds (); } if (FlagState == 2) {Waiting (); }}
void ForwardLeds () {
FirstLed = -1; LastLed = 16; for (int i = 0; i <8; i ++) {LastLed--; FirstLed ++; leds [LastLed] = CRGB:: Oq; leds [FirstLed] = CRGB:: Oq; kechikish (750); FastLED.show (); Serial.print ("oq o'tish"); Serial.print (i); Serial.println ("8dan"); } FirstLed = -1; LastLed = 16; for (int i = 0; i <8; i ++) {LastLed--; FirstLed ++; leds [LastLed] = CRGB:: Moviy; leds [FirstLed] = CRGB:: Moviy; kechikish (250); FastLED.show (); Serial.print ("Moviy o'tish"); Serial.print (i); Serial.println ("8dan"); } FirstLed = -1; LastLed = 16; for (int i = 0; i <8; i ++) {LastLed--; FirstLed ++; leds [LastLed] = CRGB:: Binafsha; leds [FirstLed] = CRGB:: Binafsha; kechikish (250); FastLED.show (); Serial.print ("Qizil pas"); Serial.print (i); Serial.println ("8dan"); } FirstLed = -1; LastLed = 16; for (int i = 0; i <8; i ++) {LastLed--; FirstLed ++; leds [LastLed] = CRGB:: Qora; leds [FirstLed] = CRGB:: Qora; kechikish (250); FastLED.show (); Serial.print ("Led o'chirilgan"); Serial.print (i); Serial.println ("8dan"); } FlagState = 2; // bayroq holatini o'zgartirish} void RevLeds () {Serial.println ("teskari"); FirstLed = 8; LastLed = 7; for (int i = 0; i <8; i ++) {LastLed ++; FirstLed-; leds [LastLed] = CRGB:: Oq; leds [FirstLed] = CRGB:: Oq; kechikish (750); FastLED.show (); Serial.print ("Oq o'tish"); Serial.print (i); Serial.println ("8dan"); } FirstLed = 8; LastLed = 7; for (int i = 0; i <8; i ++) {LastLed ++; FirstLed-; leds [LastLed] = CRGB:: Moviy; leds [FirstLed] = CRGB:: Moviy; kechikish (250); FastLED.show (); Serial.print ("Moviy o'tish"); Serial.print (i); Serial.println ("8dan"); } FirstLed = 8; LastLed = 7; for (int i = 0; i <8; i ++) {LastLed ++; FirstLed-; leds [LastLed] = CRGB:: Binafsha; leds [FirstLed] = CRGB:: Binafsha; kechikish (250); FastLED.show (); Serial.print ("Qizil pas"); Serial.print (i); Serial.println ("8dan"); }
FirstLed = 8;
LastLed = 7; for (int i = 0; i <8; i ++) {LastLed ++; FirstLed-; leds [LastLed] = CRGB:: Qora; leds [FirstLed] = CRGB:: Qora; kechikish (250); FastLED.show (); Serial.print ("Ledni o'chirish"); Serial.print (i); Serial.println ("8dan"); } FlagState = 2; // bayroq holatini o'zgartirish} void Waiting () {buttonState1 = digitalRead (buttonPin1); buttonState2 = digitalRead (buttonPin2); if (buttonState1 == HIGH) {Serial.println ("oldinga siljish"); FlagState = 0; } if if (buttonState2 == HIGH) {Serial.println ("Rev tetiklandi"); FlagState = 1; } Serial.println ("pastadir kutish tugadi"); }