Components and supplies
Arduino Nano R3
Speaker: 0.25W, 8 ohms
Pmod RTCC
NeoPixel Ring: WS2812 5050 RGB LED
HC-05 Bluetooth Module
Tools and machines
Soldering iron (generic)
3D Printer (generic)
Project description
Code
code.ino
arduino
1#define NOTE_B0 31 2#define NOTE_C1 33 3#define NOTE_CS1 35 4#define NOTE_D1 37 5#define NOTE_DS1 39 6#define NOTE_E1 41 7#define NOTE_F1 44 8#define NOTE_FS1 46 9#define NOTE_G1 49 10#define NOTE_GS1 52 11#define NOTE_A1 55 12#define NOTE_AS1 58 13#define NOTE_B1 62 14#define NOTE_C2 65 15#define NOTE_CS2 69 16#define NOTE_D2 73 17#define NOTE_DS2 78 18#define NOTE_E2 82 19#define NOTE_F2 87 20#define NOTE_FS2 93 21#define NOTE_G2 98 22#define NOTE_GS2 104 23#define NOTE_A2 110 24#define NOTE_AS2 117 25#define NOTE_B2 123 26#define NOTE_C3 131 27#define NOTE_CS3 139 28#define NOTE_D3 147 29#define NOTE_DS3 156 30#define NOTE_E3 165 31#define NOTE_F3 175 32#define NOTE_FS3 185 33#define NOTE_G3 196 34#define NOTE_GS3 208 35#define NOTE_A3 220 36#define NOTE_AS3 233 37#define NOTE_B3 247 38#define NOTE_C4 262 39#define NOTE_CS4 277 40#define NOTE_D4 294 41#define NOTE_DS4 311 42#define NOTE_E4 330 43#define NOTE_F4 349 44#define NOTE_FS4 370 45#define NOTE_G4 392 46#define NOTE_GS4 415 47#define NOTE_A4 440 48#define NOTE_AS4 466 49#define NOTE_B4 494 50#define NOTE_C5 523 51#define NOTE_CS5 554 52#define NOTE_D5 587 53#define NOTE_DS5 622 54#define NOTE_E5 659 55#define NOTE_F5 698 56#define NOTE_FS5 740 57#define NOTE_G5 784 58#define NOTE_GS5 831 59#define NOTE_A5 880 60#define NOTE_AS5 932 61#define NOTE_B5 988 62#define NOTE_C6 1047 63#define NOTE_CS6 1109 64#define NOTE_D6 1175 65#define NOTE_DS6 1245 66#define NOTE_E6 1319 67#define NOTE_F6 1397 68#define NOTE_FS6 1480 69#define NOTE_G6 1568 70#define NOTE_GS6 1661 71#define NOTE_A6 1760 72#define NOTE_AS6 1865 73#define NOTE_B6 1976 74#define NOTE_C7 2093 75#define NOTE_CS7 2217 76#define NOTE_D7 2349 77#define NOTE_DS7 2489 78#define NOTE_E7 2637 79#define NOTE_F7 2794 80#define NOTE_FS7 2960 81#define NOTE_G7 3136 82#define NOTE_GS7 3322 83#define NOTE_A7 3520 84#define NOTE_AS7 3729 85#define NOTE_B7 3951 86#define NOTE_C8 4186 87#define NOTE_CS8 4435 88#define NOTE_D8 4699 89#define NOTE_DS8 4978 90 91 92#include <Adafruit_NeoPixel.h> 93#include <DS3231.h> 94 95 96DS3231 rtc(SDA, SCL); 97 98 99Time t; 100#ifdef __AVR__ 101 #include <avr/power.h> 102#endif 103 104 105#define PIN 4 106#define PIN2 5 107#define PIN3 6 108#define PIN4 7 109#define PIN5 8 110#define PIN6 9 111#define PIN7 10 112#define NUMPIXELS 7 113Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); 114Adafruit_NeoPixel pixels2 = Adafruit_NeoPixel(NUMPIXELS, PIN2, NEO_GRB + NEO_KHZ800); 115Adafruit_NeoPixel pixels3 = Adafruit_NeoPixel(NUMPIXELS, PIN3, NEO_GRB + NEO_KHZ800); 116Adafruit_NeoPixel pixels4 = Adafruit_NeoPixel(NUMPIXELS, PIN4, NEO_GRB + NEO_KHZ800); 117Adafruit_NeoPixel pixels5 = Adafruit_NeoPixel(NUMPIXELS, PIN5, NEO_GRB + NEO_KHZ800); 118Adafruit_NeoPixel pixels6 = Adafruit_NeoPixel(NUMPIXELS, PIN6, NEO_GRB + NEO_KHZ800); 119Adafruit_NeoPixel pixels7 = Adafruit_NeoPixel(NUMPIXELS, PIN7, NEO_GRB + NEO_KHZ800); 120Adafruit_NeoPixel strip = Adafruit_NeoPixel(7, PIN, NEO_GRB + NEO_KHZ800); 121Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(7, PIN2, NEO_GRB + NEO_KHZ800); 122Adafruit_NeoPixel strip3 = Adafruit_NeoPixel(7, PIN3, NEO_GRB + NEO_KHZ800); 123Adafruit_NeoPixel strip4 = Adafruit_NeoPixel(7, PIN4, NEO_GRB + NEO_KHZ800); 124Adafruit_NeoPixel strip5 = Adafruit_NeoPixel(7, PIN5, NEO_GRB + NEO_KHZ800); 125Adafruit_NeoPixel strip6 = Adafruit_NeoPixel(7, PIN6, NEO_GRB + NEO_KHZ800); 126 127 128byte sevendisplay[19][7]= { 129 130 {1,1,1,1,1,1,0},//0 131 {0,0,1,1,0,0,0},//1 132 {0,1,1,0,1,1,1},//2 133 {0,1,1,1,1,0,1},//3 134 {1,0,1,1,0,0,1},//4 135 {1,1,0,1,1,0,1},//5 136 {1,1,0,1,1,1,1},//6 137 {0,1,1,1,0,0,0},//7 138 {1,1,1,1,1,1,1},//8 139 {1,1,1,1,1,0,1},//9 140 {1,1,0,0,1,1,0},//C 10 141 {1,1,1,0,0,0,1},//' 11 142 {1,0,1,1,0,1,1},//H 12 143 {1,0,0,0,1,1,0},//L 13 144 {1,1,0,0,0,1,0},//T2 14 145 {1,1,0,0,1,1,1},//E 15 146 {0,0,0,0,0,0,0},//bo 16 147 {1,1,1,1,0,1,0},//N 17 148 {1,1,1,0,0,1,1},//P 18 149 150 151 }; 152byte animation[7][7]= { 153 154 {1,0,0,0,0,0,0},//0 155 {0,1,0,0,0,0,0},//1 156 {0,0,1,0,0,0,0},//2 157 {0,0,0,1,0,0,0},//3 158 {0,0,0,0,1,0,0},//4 159 {0,0,0,0,0,1,0},//5 160 {0,0,0,0,0,0,1},//6 161 162 163 164 165 }; 166 167 168 byte color[10][3]= { 169 170 {0,0,255}, 171 {0,225,0}, 172 {0,255,255}, 173 {255,0,0}, 174 {255,0,255}, 175 {255,255,0}, 176 {255,255,255}, 177 {100,150,250}, 178 {255,50,30}, 179 {100,0,200}, 180 181 182 183 184 }; 185 186// Buzzer 187int speakerPin = 13; 188int alarmPin = 12; 189int x=0; 190int sayac=0; 191int dg1=0; 192int dg2=0; 193int dg3=0; 194int dg4=0; 195int d0=0; 196int d1=0; 197int d2=0; 198int d3=0; 199int d4=0; 200int d5=0; 201String data= "hello"; 202int alarmSaat=0; 203int alarmDak=0; 204byte alarmDurumu=0; 205 206// Leds 207 208 209void setup() { 210 pinMode(speakerPin, OUTPUT); 211 pinMode(alarmPin, INPUT); 212 213rtc.begin(); 214//rtc.setTime(20, 19, 40); 215//rtc.setDate(3, 10, 2018); 216 217 218 #if defined (__AVR_ATtiny85__) 219 if (F_CPU == 16000000) clock_prescale_set(clock_div_1); 220#endif 221 222 strip.begin(); 223 strip.show(); 224 225 pixels.begin(); 226 pixels2.begin(); 227 pixels3.begin(); 228 pixels4.begin(); 229 pixels5.begin(); 230 pixels6.begin(); 231 pixels7.begin(); 232 233 234 Serial.begin(9600); 235 236 237 238 239 240} 241 242void loop() { 243 t = rtc.getTime(); 244 if(Serial.available()) // Eer Bluetooth balants varsa kodalar altrr 245{ 246 /* 247 248 */ 249 250data = Serial.readStringUntil('.'); 251Serial.println(data); 252if(data=="tarih") 253{ 254String gun = Serial.readStringUntil('.'); 255String ay = Serial.readStringUntil('.'); 256String yil = Serial.readStringUntil('.'); 257 int newd=gun.toInt(); 258 int newm= ay.toInt(); 259 int newy= yil.toInt(); 260rtc.setDate(newd,newm,newy); 261data="date"; 262} 263 264 265 266if(data=="saat") 267{ 268String saat = Serial.readStringUntil('.'); 269String dak = Serial.readStringUntil('.'); 270 271 int news=saat.toInt(); 272 int newd= dak.toInt(); 273 274rtc.setTime(news, newd, 00); 275data="clock"; 276} 277 278if(data=="alarm") 279{ 280String asaat = Serial.readStringUntil('.'); 281String adak = Serial.readStringUntil('.'); 282 283 alarmSaat=asaat.toInt(); 284 alarmDak= adak.toInt(); 285 alarmDurumu=1; 286 data="clock"; 287 288 289} 290 291} 292 if(alarmDurumu==1&&alarmSaat==t.hour&&alarmDak==t.min) 293 { 294 for(int k=0; k<7;k++) 295 { 296 pixels.setPixelColor(k, pixels.Color(0,0,0)); 297 pixels2.setPixelColor(k, pixels.Color(0,0,0)); 298 pixels3.setPixelColor(k, pixels.Color(0,0,0)); 299 pixels4.setPixelColor(k, pixels.Color(0,0,0)); 300 pixels4.setPixelColor(k, pixels.Color(0,0,0)); 301 pixels5.setPixelColor(k, pixels.Color(0,0,0)); 302 pixels6.setPixelColor(k, pixels.Color(0,0,0)); 303 pixels7.setPixelColor(k, pixels.Color(0,0,0)); 304 pixels.show(); 305 pixels2.show(); 306 pixels3.show(); 307 pixels4.show(); 308 pixels5.show(); 309 pixels6.show(); 310 pixels7.show(); 311 } 312 alarmDurumu==0; 313 GameOfThrones(); 314 315 316 } 317 318 319 320 321 322 int k=1; 323 if(x==0) 324 { 325 pixels7.setPixelColor(0, pixels7.Color(color[dg4][0],color[dg4][1],color[dg4][2])); 326 pixels7.setPixelColor(1, pixels7.Color(color[dg4][0],color[dg4][1],color[dg4][2])); 327 pixels7.show(); 328 } 329 if(x==1) 330 { 331 pixels7.setPixelColor(0, pixels7.Color(0,0,0)); 332 pixels7.setPixelColor(1, pixels7.Color(0,0,0)); 333 pixels7.show(); 334 } 335 x=x+1; 336 delay(500); 337 if(x==2) 338 { 339 x=0; 340 }; 341if(data=="d1") 342{ 343 data=" "; 344 345 dg1++; 346 if(dg1==10) 347 {dg1=0;} 348 yaz(); 349 350 } 351 352 353 if(data=="d2") 354{ 355 data=" "; 356 357 dg2++; 358 if(dg2==10) 359 {dg2=0;} 360 yaz(); 361 } 362 if(data=="d3") 363{ 364 data=" "; 365 366 dg3++; 367 if(dg3==10) 368 {dg3=0;} 369 yaz(); 370 } 371 372 if(data=="d4") 373{ 374 data=" "; 375 376 dg4++; 377 if(dg4==10) 378 {dg4=0;} 379 yaz(); 380 } 381 if(data=="all") 382{sayac++; 383if(sayac==10) 384{sayac=0;} 385dg1=sayac; 386dg2=sayac; 387dg3=sayac; 388data=" "; 389yaz(); 390 } 391if(data=="hello") 392{ 393 d0=12; 394 d1=15; 395 d2=13; 396 d3=13; 397 d4=0; 398 d5=16; 399yaz(); 400} 401 402//clock 403 404if(data=="clock") 405{ 406d0=(t.hour)/10; 407d1=(t.hour)%10; 408d2=(t.min)/10; 409d3=(t.min)%10; 410d4=(t.sec)/10; 411d5=(t.sec)%10; 412yaz(); 413} 414 415 416if(data=="date") 417{ 418 d0=(t.date)/10; 419 d1=(t.date)%10; 420 d2=(t.mon)/10; 421 d3=(t.mon)%10; 422 d5=(t.year)%100; 423 d4=(d5)/10; 424 d5=(d5)%10; 425 yaz(); 426} 427if(data=="temp") 428{ 429int sayi=(rtc.getTemp())*100; 430d0=sayi/1000; 431d1=sayi%1000; 432d1=d1/100; 433d2=sayi%100; 434d2=d2/10; 435d3=(sayi)%10; 436d4=10; 437d5=11; 438yaz(); 439 440 } 441 442if(data=="animation") 443{ 444 445 446 447 448 449 450 451 452for(int g=0;g<NUMPIXELS;g++) 453 { delay(500); 454for(int i=0;i<NUMPIXELS;i++) 455 { 456 457 if(animation[g][i]==1) 458 { 459 pixels.setPixelColor(i, pixels.Color(color[dg1][0],color[dg1][1],color[dg1][2])); 460 pixels.show(); 461 } 462 else 463 { 464 pixels.setPixelColor(i, pixels.Color(0,0,0)); 465 pixels.show(); 466 } 467 468 if(animation[g][i]==1) 469 { 470 pixels2.setPixelColor(i, pixels2.Color(color[dg1][0],color[dg1][1],color[dg1][2])); 471 pixels2.show(); 472 } 473 else 474 { 475 pixels2.setPixelColor(i, pixels2.Color(0,0,0)); 476 pixels2.show(); 477 } 478 479 480 481 482 483 if(animation[g][i]==1) 484 { 485 pixels3.setPixelColor(i, pixels3.Color(color[dg2][0],color[dg2][1],color[dg2][2])); 486 pixels3.show(); 487 } 488 else 489 { 490 pixels3.setPixelColor(i, pixels3.Color(0,0,0)); 491 pixels3.show(); 492 } 493 494 if(animation[g][i]==1) 495 { 496 pixels4.setPixelColor(i, pixels4.Color(color[dg2][0],color[dg2][1],color[dg2][2])); 497 pixels4.show(); 498 } 499 else 500 { 501 pixels4.setPixelColor(i, pixels4.Color(0,0,0)); 502 pixels4.show(); 503 504 } 505 506 507 508 if(animation[g][i]==1) 509 { 510 pixels5.setPixelColor(i, pixels5.Color(color[dg3][0],color[dg3][1],color[dg3][2])); 511 pixels5.show(); 512 } 513 else 514 { 515 pixels5.setPixelColor(i, pixels5.Color(0,0,0)); 516 pixels5.show(); 517 } 518 519 if(animation[g][i]==1) 520 { 521 pixels6.setPixelColor(i, pixels6.Color(color[dg3][0],color[dg3][1],color[dg3][2])); 522 pixels6.show(); 523 } 524 else 525 { 526 pixels6.setPixelColor(i, pixels6.Color(0,0,00)); 527 pixels6.show(); 528 529 } 530 } 531 532} 533 534 535 colorWipe(strip.Color(255, 0, 0), 100); // Red 536 colorWipe(strip2.Color(0, 255, 0), 100); // Green 537 colorWipe(strip3.Color(0, 0, 255), 100); // Blue 538 colorWipe(strip4.Color(0, 0, 0, 255), 100); // White RGBW 539 540 541 rainbow(50); 542 543yaz(); 544 545 546 547 548data=" "; 549} 550 551 552} 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574void yaz() 575{ 576for(int i=0;i<NUMPIXELS;i++) 577 { 578 579 if(sevendisplay[d0][i]==1) 580 { 581 pixels.setPixelColor(i, pixels.Color(color[dg1][0],color[dg1][1],color[dg1][2])); 582 pixels.show(); 583 } 584 else 585 { 586 pixels.setPixelColor(i, pixels.Color(0,0,0)); 587 pixels.show(); 588 } 589 590 if(sevendisplay[d1][i]==1) 591 { 592 pixels2.setPixelColor(i, pixels2.Color(color[dg1][0],color[dg1][1],color[dg1][2])); 593 pixels2.show(); 594 } 595 else 596 { 597 pixels2.setPixelColor(i, pixels2.Color(0,0,0)); 598 pixels2.show(); 599 } 600 601 602 603 604 605 if(sevendisplay[d2][i]==1) 606 { 607 pixels3.setPixelColor(i, pixels3.Color(color[dg2][0],color[dg2][1],color[dg2][2])); 608 pixels3.show(); 609 } 610 else 611 { 612 pixels3.setPixelColor(i, pixels3.Color(0,0,0)); 613 pixels3.show(); 614 } 615 616 if(sevendisplay[d3][i]==1) 617 { 618 pixels4.setPixelColor(i, pixels4.Color(color[dg2][0],color[dg2][1],color[dg2][2])); 619 pixels4.show(); 620 } 621 else 622 { 623 pixels4.setPixelColor(i, pixels4.Color(0,0,0)); 624 pixels4.show(); 625 626 } 627 628 629 630 if(sevendisplay[d4][i]==1) 631 { 632 pixels5.setPixelColor(i, pixels5.Color(color[dg3][0],color[dg3][1],color[dg3][2])); 633 pixels5.show(); 634 } 635 else 636 { 637 pixels5.setPixelColor(i, pixels5.Color(0,0,0)); 638 pixels5.show(); 639 } 640 641 if(sevendisplay[d5][i]==1) 642 { 643 pixels6.setPixelColor(i, pixels6.Color(color[dg3][0],color[dg3][1],color[dg3][2])); 644 pixels6.show(); 645 } 646 else 647 { 648 pixels6.setPixelColor(i, pixels6.Color(0,0,00)); 649 pixels6.show(); 650 651 } 652 } 653 654} 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669void ilumina(int note){ 670 if(note == NOTE_G4 || note == NOTE_G3 || note == NOTE_GS3) { 671 pixels.setPixelColor(0, pixels.Color(250,0,0)); 672 pixels.show(); 673 pixels2.setPixelColor(0, pixels2.Color(250,0,0)); 674 pixels2.show(); 675 pixels3.setPixelColor(0, pixels3.Color(250,0,0)); 676 pixels3.show(); 677 pixels4.setPixelColor(0, pixels4.Color(250,0,0)); 678 pixels4.show(); 679 pixels5.setPixelColor(0, pixels5.Color(250,0,0)); 680 pixels5.show(); 681 pixels6.setPixelColor(0, pixels6.Color(250,0,0)); 682 pixels6.show(); 683 684 685 686 687 688 689 690 } else if (note == NOTE_C4) { 691 pixels.setPixelColor(1, pixels.Color(0,250,0)); 692 pixels.show(); 693 pixels2.setPixelColor(1, pixels2.Color(0,250,0)); 694 pixels2.show(); 695 pixels3.setPixelColor(1, pixels3.Color(0,250,0)); 696 pixels3.show(); 697 pixels4.setPixelColor(1, pixels4.Color(0,250,0)); 698 pixels4.show(); 699 pixels5.setPixelColor(1, pixels5.Color(0,250,0)); 700 pixels5.show(); 701 pixels6.setPixelColor(1, pixels6.Color(0,250,0)); 702 pixels6.show(); 703 704 } else if(note == NOTE_AS3) { 705 pixels.setPixelColor(2, pixels.Color(0,0,250)); 706 pixels.show(); 707 pixels2.setPixelColor(2, pixels2.Color(0,0,250)); 708 pixels2.show(); 709 pixels3.setPixelColor(2, pixels3.Color(0,0,250)); 710 pixels3.show(); 711 pixels4.setPixelColor(2, pixels4.Color(0,0,250)); 712 pixels4.show(); 713 pixels5.setPixelColor(2, pixels5.Color(0,250,0)); 714 pixels5.show(); 715 pixels6.setPixelColor(2, pixels6.Color(0,250,0)); 716 pixels6.show(); 717 718 } else if (note == NOTE_DS4) { 719 pixels.setPixelColor(3, pixels.Color(250,0,0)); 720 pixels.show(); 721 pixels3.setPixelColor(3, pixels3.Color(250,0,0)); 722 pixels3.show(); 723 pixels2.setPixelColor(3, pixels2.Color(250,0,0)); 724 pixels2.show(); 725 pixels4.setPixelColor(3, pixels4.Color(250,0,0)); 726 pixels4.show(); 727 728 pixels5.setPixelColor(3, pixels5.Color(250,0,0)); 729 pixels5.show(); 730 pixels6.setPixelColor(3, pixels6.Color(250,0,0)); 731 pixels6.show(); 732 733 734 735 736 } else if (note == NOTE_D4) { 737 pixels.setPixelColor(4, pixels.Color(0,250,0)); 738 pixels.show(); 739 pixels2.setPixelColor(4, pixels2.Color(0,250,0)); 740 pixels2.show(); 741 pixels3.setPixelColor(4, pixels3.Color(0,250,0)); 742 pixels3.show(); 743 pixels4.setPixelColor(4, pixels4.Color(0,250,0)); 744 pixels4.show(); 745 746 pixels5.setPixelColor(4, pixels5.Color(0,250,0)); 747 pixels5.show(); 748 pixels6.setPixelColor(4, pixels6.Color(0,250,0)); 749 pixels6.show(); 750 751 752 } else if (note == NOTE_F4) { 753 pixels.setPixelColor(5, pixels.Color(0,0,250)); 754 pixels.show(); 755 pixels3.setPixelColor(5, pixels3.Color(0,0,250)); 756 pixels3.show(); 757 pixels2.setPixelColor(5, pixels2.Color(0,0,250)); 758 pixels2.show(); 759 pixels4.setPixelColor(5, pixels4.Color(0,0,250)); 760 pixels4.show(); 761 762 pixels5.setPixelColor(5, pixels5.Color(0,0,250)); 763 pixels5.show(); 764 pixels6.setPixelColor(5, pixels6.Color(0,0,250)); 765 pixels6.show(); 766 } else if (note == NOTE_F3) { 767 pixels.setPixelColor(7, pixels.Color(250,0,0)); 768 pixels.show(); 769 } else if(note == NOTE_E4) { 770 pixels.setPixelColor(6, pixels.Color(0,0,250)); 771 pixels.show(); 772 pixels3.setPixelColor(6, pixels3.Color(0,0,250)); 773 pixels3.show(); 774 pixels2.setPixelColor(6, pixels2.Color(0,0,250)); 775 pixels2.show(); 776 pixels4.setPixelColor(6, pixels4.Color(0,0,250)); 777 pixels4.show(); 778 779 780 pixels5.setPixelColor(6, pixels5.Color(0,0,250)); 781 pixels5.show(); 782 pixels6.setPixelColor(6, pixels6.Color(0,0,250)); 783 pixels6.show(); 784 } 785} 786 787void apaga(int note){ 788 if(note == NOTE_G4 || note == NOTE_G3 || note == NOTE_GS3) { 789 pixels.setPixelColor(0, pixels.Color(0,0,0)); 790 pixels.show(); 791 pixels3.setPixelColor(0, pixels3.Color(0,0,0)); 792 pixels3.show(); 793 pixels4.setPixelColor(0, pixels4.Color(0,0,0)); 794 pixels4.show(); 795 pixels2.setPixelColor(0, pixels2.Color(0,0,0)); 796 pixels2.show(); 797 798 799 800 pixels5.setPixelColor(0, pixels5.Color(0,0,0)); 801 pixels5.show(); 802 pixels6.setPixelColor(0, pixels6.Color(0,0,0)); 803 pixels6.show(); 804 } else if (note == NOTE_C4) { 805 pixels.setPixelColor(1, pixels.Color(0,0,0)); 806 pixels.show(); 807 pixels3.setPixelColor(1, pixels3.Color(0,0,0)); 808 pixels3.show(); 809 pixels4.setPixelColor(1, pixels4.Color(0,0,0)); 810 pixels4.show(); 811 pixels2.setPixelColor(1, pixels2.Color(0,0,0)); 812 pixels2.show(); 813 814 pixels5.setPixelColor(1, pixels5.Color(0,0,0)); 815 pixels5.show(); 816 pixels6.setPixelColor(1, pixels6.Color(0,0,0)); 817 pixels6.show(); 818 } else if(note == NOTE_AS3) { 819 pixels.setPixelColor(2, pixels.Color(0,0,0)); 820 pixels.show(); 821 pixels2.setPixelColor(2, pixels2.Color(0,0,0)); 822 pixels2.show(); 823 pixels3.setPixelColor(2, pixels3.Color(0,0,0)); 824 pixels3.show(); 825 pixels4.setPixelColor(2, pixels4.Color(0,0,0)); 826 pixels4.show(); 827 828 829 830 pixels5.setPixelColor(2, pixels5.Color(0,0,0)); 831 pixels5.show(); 832 pixels6.setPixelColor(2, pixels6.Color(0,0,0)); 833 pixels6.show(); 834 } else if (note == NOTE_DS4) { 835 pixels.setPixelColor(3, pixels.Color(0,0,0)); 836 pixels.show(); 837 pixels2.setPixelColor(3, pixels2.Color(0,0,0)); 838 pixels2.show(); 839 pixels3.setPixelColor(3, pixels3.Color(0,0,0)); 840 pixels3.show(); 841 pixels4.setPixelColor(3, pixels4.Color(0,0,0)); 842 pixels4.show(); 843 844 pixels5.setPixelColor(3, pixels5.Color(0,0,0)); 845 pixels5.show(); 846 pixels6.setPixelColor(3, pixels6.Color(0,0,0)); 847 pixels6.show(); 848 } else if (note == NOTE_D4) { 849 pixels.setPixelColor(4, pixels.Color(0,0,0)); 850 pixels.show(); 851 pixels2.setPixelColor(4, pixels2.Color(0,0,0)); 852 pixels2.show(); 853 pixels3.setPixelColor(4, pixels3.Color(0,0,0)); 854 pixels3.show(); 855 pixels4.setPixelColor(4, pixels4.Color(0,0,0)); 856 pixels4.show(); 857 pixels5.setPixelColor(4, pixels5.Color(0,0,0)); 858 pixels5.show(); 859 pixels6.setPixelColor(4, pixels6.Color(0,0,0)); 860 pixels6.show(); 861 862 } else if (note == NOTE_F4) { 863 pixels.setPixelColor(5, pixels.Color(0,0,0)); 864 pixels.show(); 865 pixels2.setPixelColor(5, pixels2.Color(0,0,0)); 866 pixels2.show(); 867 pixels3.setPixelColor(5, pixels3.Color(0,0,0)); 868 pixels3.show(); 869 pixels4.setPixelColor(5, pixels4.Color(0,0,0)); 870 pixels4.show(); 871 pixels5.setPixelColor(5, pixels5.Color(0,0,0)); 872 pixels5.show(); 873 pixels6.setPixelColor(5, pixels6.Color(0,0,0)); 874 pixels6.show(); 875 } else if (note == NOTE_F3) { 876 pixels.setPixelColor(7, pixels.Color(0,0,0)); 877 pixels.show(); 878 } else if(note == NOTE_E4) { 879 pixels.setPixelColor(6, pixels.Color(0,0,0)); 880 pixels.show(); 881 882 pixels2.setPixelColor(6, pixels2.Color(0,0,0)); 883 pixels2.show(); 884 pixels3.setPixelColor(6, pixels3.Color(0,0,0)); 885 pixels3.show(); 886 pixels4.setPixelColor(6, pixels4.Color(0,0,0)); 887 pixels4.show(); 888 pixels5.setPixelColor(6, pixels5.Color(0,0,0)); 889 pixels5.show(); 890 pixels6.setPixelColor(6, pixels6.Color(0,0,0)); 891 pixels6.show(); 892 } 893} 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908void GameOfThrones() { 909 for(int i=0; i<4; i++) { 910 tone(speakerPin, NOTE_G4); 911 ilumina(NOTE_G4); 912 delay(500); 913 noTone(speakerPin); 914 apaga(NOTE_G4); 915 916 tone(speakerPin, NOTE_C4); 917 ilumina(NOTE_C4); 918 delay(500); 919 noTone(speakerPin); 920 apaga(NOTE_C4); 921 922 tone(speakerPin, NOTE_DS4); 923 ilumina(NOTE_DS4); 924 delay(250); 925 noTone(speakerPin); 926 apaga(NOTE_DS4); 927 928 tone(speakerPin, NOTE_F4); 929 ilumina(NOTE_F4); 930 delay(250); 931 noTone(speakerPin); 932 apaga(NOTE_F4); 933 } 934 935 for(int i=0; i<4; i++){ 936 tone(speakerPin, NOTE_G4); 937 ilumina(NOTE_G4); 938 delay(500); 939 noTone(speakerPin); 940 apaga(NOTE_G4); 941 942 tone(speakerPin, NOTE_C4); 943 ilumina(NOTE_C4); 944 delay(500); 945 noTone(speakerPin); 946 apaga(NOTE_C4); 947 948 tone(speakerPin, NOTE_E4); 949 ilumina(NOTE_E4); 950 delay(250); 951 noTone(speakerPin); 952 apaga(NOTE_E4); 953 954 tone(speakerPin, NOTE_F4); 955 ilumina(NOTE_F4); 956 delay(250); 957 noTone(speakerPin); 958 apaga(NOTE_F4); 959 } 960 961 tone(speakerPin, NOTE_G4); 962 ilumina(NOTE_G4); 963 delay(1500); 964 noTone(speakerPin); 965 apaga(NOTE_G4); 966 967 tone(speakerPin, NOTE_C4); 968 ilumina(NOTE_C4); 969 delay(1500); 970 apaga(NOTE_C4); 971 972// 973 tone(speakerPin, NOTE_E4); 974 ilumina(NOTE_E4); 975 delay(250); 976 apaga(NOTE_C4); 977 978 tone(speakerPin, NOTE_F4); 979 ilumina(NOTE_F4); 980 delay(250); 981 apaga(NOTE_C4); 982// 983 tone(speakerPin, NOTE_G4); 984 ilumina(NOTE_G4); 985 delay(1000); 986 noTone(speakerPin); 987 apaga(NOTE_G4); 988 989 tone(speakerPin, NOTE_C4); 990 ilumina(NOTE_C4); 991 delay(1000); 992 apaga(NOTE_C4); 993 994 tone(speakerPin, NOTE_DS4); 995 ilumina(NOTE_DS4); 996 delay(250); 997 noTone(speakerPin); 998 apaga(NOTE_DS4); 999 1000 tone(speakerPin, NOTE_F4); 1001 ilumina(NOTE_F4); 1002 delay(250); 1003 noTone(speakerPin); 1004 apaga(NOTE_F4); 1005 1006 for(int i=0; i<3; i++) { 1007 1008 tone(speakerPin, NOTE_D4); 1009 ilumina(NOTE_D4); 1010 delay(500); 1011 noTone(speakerPin); 1012 apaga(NOTE_D4); 1013 1014 tone(speakerPin, NOTE_G3); 1015 ilumina(NOTE_G3); 1016 delay(500); 1017 noTone(speakerPin); 1018 apaga(NOTE_G3); 1019 1020 tone(speakerPin, NOTE_AS3); 1021 ilumina(NOTE_AS3); 1022 delay(250); 1023 noTone(speakerPin); 1024 apaga(NOTE_AS3); 1025 1026 tone(speakerPin, NOTE_C4); 1027 ilumina(NOTE_C4); 1028 delay(250); 1029 noTone(speakerPin); 1030 apaga(NOTE_C4); 1031 1032 1033 } 1034 1035 1036 1037 tone(speakerPin, NOTE_D4); 1038 ilumina(NOTE_D4); 1039 delay(1500); 1040 noTone(speakerPin); 1041 apaga(NOTE_D4); 1042 1043 tone(speakerPin, NOTE_F4); 1044 ilumina(NOTE_F4); 1045 delay(1500); 1046 noTone(speakerPin); 1047 apaga(NOTE_F4); 1048 1049 tone(speakerPin, NOTE_AS3); 1050 ilumina(NOTE_AS3); 1051 delay(1000); 1052 noTone(speakerPin); 1053 apaga(NOTE_AS3); 1054 1055 tone(speakerPin, NOTE_DS4); 1056 ilumina(NOTE_DS4); 1057 delay(250); 1058 noTone(speakerPin); 1059 apaga(NOTE_DS4); 1060 1061 tone(speakerPin, NOTE_D4); 1062 ilumina(NOTE_D4); 1063 delay(250); 1064 noTone(speakerPin); 1065 apaga(NOTE_D4); 1066 1067 tone(speakerPin, NOTE_F4); 1068 ilumina(NOTE_F4); 1069 delay(1000); 1070 noTone(speakerPin); 1071 apaga(NOTE_F4); 1072 1073 tone(speakerPin, NOTE_AS3); 1074 ilumina(NOTE_AS3); 1075 delay(1000); 1076 noTone(speakerPin); 1077 apaga(NOTE_AS3); 1078 1079 tone(speakerPin, NOTE_DS4); 1080 ilumina(NOTE_DS4); 1081 delay(250); 1082 noTone(speakerPin); 1083 apaga(NOTE_DS4); 1084 1085 tone(speakerPin, NOTE_D4); 1086 ilumina(NOTE_D4); 1087 delay(250); 1088 noTone(speakerPin); 1089 apaga(NOTE_D4); 1090 1091 tone(speakerPin, NOTE_C4); 1092 ilumina(NOTE_C4); 1093 delay(500); 1094 noTone(speakerPin); 1095 apaga(NOTE_C4); 1096 1097 for(int i=0; i<3; i++) { 1098 tone(speakerPin, NOTE_GS3); 1099 ilumina(NOTE_GS3); 1100 delay(250); 1101 noTone(speakerPin); 1102 apaga(NOTE_GS3); 1103 1104 tone(speakerPin, NOTE_AS3); 1105 ilumina(NOTE_AS3); 1106 delay(250); 1107 noTone(speakerPin); 1108 apaga(NOTE_AS3); 1109 1110 tone(speakerPin, NOTE_C4); 1111 ilumina(NOTE_C4); 1112 delay(500); 1113 noTone(speakerPin); 1114 apaga(NOTE_C4); 1115 1116 tone(speakerPin, NOTE_F3); 1117 ilumina(NOTE_F3); 1118 delay(500); 1119 noTone(speakerPin); 1120 apaga(NOTE_F3); 1121 } 1122 1123 tone(speakerPin, NOTE_G4); 1124 ilumina(NOTE_G4); 1125 delay(1000); 1126 noTone(speakerPin); 1127 apaga(NOTE_G4); 1128 1129 tone(speakerPin, NOTE_C4); 1130 ilumina(NOTE_C4); 1131 delay(1000); 1132 noTone(speakerPin); 1133 apaga(NOTE_C4); 1134 1135 tone(speakerPin, NOTE_DS4); 1136 ilumina(NOTE_DS4); 1137 delay(250); 1138 noTone(speakerPin); 1139 apaga(NOTE_DS4); 1140 1141 tone(speakerPin, NOTE_F4); 1142 ilumina(NOTE_F4); 1143 delay(250); 1144 noTone(speakerPin); 1145 apaga(NOTE_F4); 1146 1147 tone(speakerPin, NOTE_G4); 1148 ilumina(NOTE_G4); 1149 delay(1000); 1150 noTone(speakerPin); 1151 apaga(NOTE_G4); 1152 1153 tone(speakerPin, NOTE_C4); 1154 ilumina(NOTE_C4); 1155 delay(1000); 1156 noTone(speakerPin); 1157 apaga(NOTE_C4); 1158 1159 tone(speakerPin, NOTE_DS4); 1160 ilumina(NOTE_DS4); 1161 delay(250); 1162 noTone(speakerPin); 1163 apaga(NOTE_DS4); 1164 1165 tone(speakerPin, NOTE_F4); 1166 ilumina(NOTE_F4); 1167 delay(250); 1168 noTone(speakerPin); 1169 apaga(NOTE_F4); 1170 1171 tone(speakerPin, NOTE_D4); 1172 ilumina(NOTE_D4); 1173 delay(500); 1174 noTone(speakerPin); 1175 apaga(NOTE_D4); 1176 1177 for(int i=0; i<4; i++) { 1178 tone(speakerPin, NOTE_G3); 1179 ilumina(NOTE_G3); 1180 delay(500); 1181 noTone(speakerPin); 1182 apaga(NOTE_G3); 1183 1184 tone(speakerPin, NOTE_AS3); 1185 ilumina(NOTE_AS3); 1186 delay(250); 1187 noTone(speakerPin); 1188 apaga(NOTE_AS3); 1189 1190 tone(speakerPin, NOTE_C4); 1191 ilumina(NOTE_C4); 1192 delay(250); 1193 noTone(speakerPin); 1194 apaga(NOTE_C4); 1195 1196 tone(speakerPin, NOTE_D4); 1197 ilumina(NOTE_D4); 1198 delay(500); 1199 noTone(speakerPin); 1200 apaga(NOTE_D4); 1201 } 1202} 1203 1204 1205 1206 1207 1208void colorWipe(uint32_t c, uint8_t wait) { 1209 for(uint16_t i=0; i<strip.numPixels(); i++) { 1210 strip.setPixelColor(i, c); 1211 strip2.setPixelColor(i, c); 1212 strip3.setPixelColor(i, c); 1213 strip4.setPixelColor(i, c); 1214 strip5.setPixelColor(i, c); 1215 strip6.setPixelColor(i, c); 1216 strip.show(); 1217 strip2.show(); 1218 strip3.show(); 1219 strip4.show(); 1220 strip5.show(); 1221 strip6.show(); 1222 delay(wait); 1223 } 1224} 1225 1226void rainbow(uint8_t wait) { 1227 uint16_t i, j; 1228 1229 for(j=0; j<256; j++) { 1230 for(i=0; i<strip.numPixels(); i++) { 1231 strip.setPixelColor(i, Wheel((i+j) & 255)); 1232 strip2.setPixelColor(i, Wheel((i+j) & 255)); 1233 strip3.setPixelColor(i, Wheel((i+j) & 255)); 1234 strip4.setPixelColor(i, Wheel((i+j) & 255)); 1235 strip5.setPixelColor(i, Wheel((i+j) & 255)); 1236 strip6.setPixelColor(i, Wheel((i+j) & 255)); 1237 } 1238 strip.show(); 1239 strip2.show(); 1240 strip3.show(); 1241 strip4.show(); 1242 strip5.show(); 1243 strip6.show(); 1244 delay(wait); 1245 } 1246} 1247 1248// Slightly different, this makes the rainbow equally distributed throughout 1249void rainbowCycle(uint8_t wait) { 1250 uint16_t i, j; 1251 1252 for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel 1253 for(i=0; i< strip.numPixels(); i++) { 1254 strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); 1255 strip2.setPixelColor(i, Wheel(((i * 256 / strip2.numPixels()) + j) & 255)); 1256 strip3.setPixelColor(i, Wheel(((i * 256 / strip3.numPixels()) + j) & 255)); 1257 strip4.setPixelColor(i, Wheel(((i * 256 / strip4.numPixels()) + j) & 255)); 1258 strip5.setPixelColor(i, Wheel(((i * 256 / strip5.numPixels()) + j) & 255)); 1259 strip6.setPixelColor(i, Wheel(((i * 256 / strip6.numPixels()) + j) & 255)); 1260 1261 } 1262 strip.show(); 1263 strip2.show(); 1264 strip3.show(); 1265 strip4.show(); 1266 strip5.show(); 1267 strip6.show(); 1268 delay(wait); 1269 } 1270} 1271 1272//Theatre-style crawling lights. 1273void theaterChase(uint32_t c, uint8_t wait) { 1274 for (int j=0; j<10; j++) { //do 10 cycles of chasing 1275 for (int q=0; q < 3; q++) { 1276 for (int i=0; i < strip.numPixels(); i=i+3) { 1277 strip.setPixelColor(i+q, c); //turn every third pixel on 1278 } 1279 strip.show(); 1280 1281 delay(wait); 1282 1283 for (int i=0; i < strip.numPixels(); i=i+3) { 1284 strip.setPixelColor(i+q, 0); //turn every third pixel off 1285 } 1286 } 1287 } 1288} 1289 1290//Theatre-style crawling lights with rainbow effect 1291void theaterChaseRainbow(uint8_t wait) { 1292 for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel 1293 for (int q=0; q < 3; q++) { 1294 for (int i=0; i < strip.numPixels(); i=i+3) { 1295 strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on 1296 strip2.setPixelColor(i+q, Wheel( (i+j) % 255)); 1297 strip3.setPixelColor(i+q, Wheel( (i+j) % 255)); 1298 strip4.setPixelColor(i+q, Wheel( (i+j) % 255)); 1299 strip5.setPixelColor(i+q, Wheel( (i+j) % 255)); 1300 strip6.setPixelColor(i+q, Wheel( (i+j) % 255)); 1301 } 1302 strip.show(); 1303 strip2.show(); 1304 strip3.show(); 1305 strip4.show(); 1306 strip5.show(); 1307 strip6.show(); 1308 1309 delay(wait); 1310 1311 for (int i=0; i < strip.numPixels(); i=i+3) { 1312 strip.setPixelColor(i+q, 0); //turn every third pixel off 1313 1314 } 1315 } 1316 } 1317} 1318 1319// Input a value 0 to 255 to get a color value. 1320// The colours are a transition r - g - b - back to r. 1321uint32_t Wheel(byte WheelPos) { 1322 WheelPos = 255 - WheelPos; 1323 if(WheelPos < 85) { 1324 return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); 1325 } 1326 if(WheelPos < 170) { 1327 WheelPos -= 85; 1328 return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); 1329 } 1330 WheelPos -= 170; 1331 return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); 1332} 1333
Downloadable files
Electronic Circuit
Electronic Circuit
Electronic Circuit
Electronic Circuit
Comments
Only logged in users can leave comments