Components and supplies
LED (generic)
Arduino UNO
Apps and platforms
Arduino IDE
Project description
Code
_12_10_16 (1).ino
arduino
Connect LEDs to pins 2, 3, 4, and 5. Run the program and it will display the first 900 or so digits of pi. You can also delete the long list of functions at the bottom and replace it with any number you want. Just make sure to treat each digit of the number as a function.
1void setup() { 2 // put your setup code here, to run once: 3 pinMode(2, OUTPUT); 4 pinMode(3, OUTPUT); 5 pinMode(4, OUTPUT); 6 pinMode(5, OUTPUT); 7} 8 9void reset(int x) { 10 delay(x); 11 digitalWrite(2, LOW); 12 digitalWrite(3, LOW); 13 digitalWrite(4, LOW); 14 digitalWrite(5, LOW); 15} 16 17void ze(int x) { 18 digitalWrite(2, LOW); 19 digitalWrite(3, LOW); 20 digitalWrite(4, LOW); 21 digitalWrite(5, LOW); 22 reset(x); 23} 24 25void on(int x) { 26 digitalWrite(2, LOW); 27 digitalWrite(3, LOW); 28 digitalWrite(4, LOW); 29 digitalWrite(5, HIGH); 30 reset(x); 31} 32 33void tw(int x) { 34 digitalWrite(2, LOW); 35 digitalWrite(3, LOW); 36 digitalWrite(4, HIGH); 37 digitalWrite(5, LOW); 38 reset(x); 39} 40 41void th(int x) { 42 digitalWrite(2, LOW); 43 digitalWrite(3, LOW); 44 digitalWrite(4, HIGH); 45 digitalWrite(5, HIGH); 46 reset(x); 47} 48 49void fo(int x) { 50 digitalWrite(2, LOW); 51 digitalWrite(3, HIGH); 52 digitalWrite(4, LOW); 53 digitalWrite(5, LOW); 54 reset(x); 55} 56 57void fi(int x) { 58 digitalWrite(2, LOW); 59 digitalWrite(3, HIGH); 60 digitalWrite(4, LOW); 61 digitalWrite(5, HIGH); 62 reset(x); 63} 64 65void si(int x) { 66 digitalWrite(2, LOW); 67 digitalWrite(3, HIGH); 68 digitalWrite(4, HIGH); 69 digitalWrite(5, LOW); 70 reset(x); 71} 72 73void se(int x) { 74 digitalWrite(2, LOW); 75 digitalWrite(3, HIGH); 76 digitalWrite(4, HIGH); 77 digitalWrite(5, HIGH); 78 reset(x); 79} 80 81void ei(int x) { 82 digitalWrite(2, HIGH); 83 digitalWrite(3, LOW); 84 digitalWrite(4, LOW); 85 digitalWrite(5, LOW); 86 reset(x); 87} 88 89void ni(int x) { 90 digitalWrite(2, HIGH); 91 digitalWrite(3, LOW); 92 digitalWrite(4, LOW); 93 digitalWrite(5, HIGH); 94 reset(x); 95} 96 97void loop() { 98 // put your main code here, to run repeatedly: 99 th(500); 100 on(500); 101 fo(500); 102 on(500); 103 fi(500); 104 ni(500); 105 tw(500); 106 si(500); 107 fi(500); 108 th(500); 109 fi(500); 110 ei(500); 111 ni(500); 112 se(500); 113 ni(500); 114 th(500); 115 tw(500); 116 th(500); 117 ei(500); 118 fo(500); 119 si(500); 120 tw(500); 121 si(500); 122 fo(500); 123 th(500); 124 th(500); 125 ei(500); 126 th(500); 127 tw(500); 128 se(500); 129 ni(500); 130 fi(500); 131 ze(500); 132 tw(500); 133 ei(500); 134 ei(500); 135 fo(500); 136 on(500); 137 ni(500); 138 se(500); 139 on(500); 140 si(500); 141 ni(500); 142 th(500); 143 ni(500); 144 ni(500); 145 th(500); 146 se(500); 147 fi(500); 148 on(500); 149 ze(500); 150 fi(500); 151 ei(500); 152 tw(500); 153 ze(500); 154 ni(500); 155 se(500); 156 fo(500); 157 ni(500); 158 fo(500); 159 fo(500); 160 fi(500); 161 ni(500); 162 tw(500); 163 th(500); 164 ze(500); 165 se(500); 166 ei(500); 167 on(500); 168 si(500); 169 fo(500); 170 ze(500); 171 si(500); 172 tw(500); 173 ei(500); 174 si(500); 175 tw(500); 176 ze(500); 177 ei(500); 178 ni(500); 179 ni(500); 180 ei(500); 181 si(500); 182 tw(500); 183 ei(500); 184 ze(500); 185 th(500); 186 fo(500); 187 ei(500); 188 tw(500); 189 fi(500); 190 th(500); 191 fo(500); 192 tw(500); 193 on(500); 194 on(500); 195 se(500); 196 ze(500); 197 si(500); 198 se(500); 199 ni(500); 200 ei(500); 201 tw(500); 202 on(500); 203 fo(500); 204 ei(500); 205 ze(500); 206 ei(500); 207 si(500); 208 fi(500); 209 on(500); 210 th(500); 211 tw(500); 212 ei(500); 213 tw(500); 214 th(500); 215 ze(500); 216 si(500); 217 si(500); 218 fo(500); 219 se(500); 220 ze(500); 221 ni(500); 222 th(500); 223 ei(500); 224 fo(500); 225 fo(500); 226 si(500); 227 ze(500); 228 ni(500); 229 fi(500); 230 fi(500); 231 ze(500); 232 fi(500); 233 ei(500); 234 tw(500); 235 tw(500); 236 th(500); 237 on(500); 238 se(500); 239 tw(500); 240 fi(500); 241 th(500); 242 fi(500); 243 ni(500); 244 fo(500); 245 ze(500); 246 ei(500); 247 on(500); 248 tw(500); 249 ei(500); 250 fo(500); 251 ei(500); 252 on(500); 253 on(500); 254 on(500); 255 se(500); 256 fo(500); 257 fi(500); 258 ze(500); 259 tw(500); 260 ei(500); 261 fo(500); 262 on(500); 263 ze(500); 264 tw(500); 265 se(500); 266 ze(500); 267 on(500); 268 ni(500); 269 th(500); 270 ei(500); 271 fi(500); 272 tw(500); 273 on(500); 274 on(500); 275 ze(500); 276 fi(500); 277 fi(500); 278 fi(500); 279 ni(500); 280 si(500); 281 fo(500); 282 fo(500); 283 si(500); 284 tw(500); 285 tw(500); 286 ni(500); 287 fo(500); 288 ei(500); 289 ni(500); 290 fi(500); 291 fo(500); 292 ni(500); 293 th(500); 294 ze(500); 295 th(500); 296 ei(500); 297 on(500); 298 ni(500); 299 si(500); 300 fo(500); 301 fo(500); 302 tw(500); 303 ei(500); 304 ei(500); 305 on(500); 306 ze(500); 307 ni(500); 308 se(500); 309 fi(500); 310 si(500); 311 si(500); 312 fi(500); 313 ni(500); 314 th(500); 315 th(500); 316 fo(500); 317 fo(500); 318 si(500); 319 on(500); 320 tw(500); 321 ei(500); 322 fo(500); 323 se(500); 324 fi(500); 325 si(500); 326 fo(500); 327 ei(500); 328 tw(500); 329 th(500); 330 th(500); 331 se(500); 332 ei(500); 333 si(500); 334 se(500); 335 ei(500); 336 th(500); 337 on(500); 338 si(500); 339 fi(500); 340 tw(500); 341 se(500); 342 on(500); 343 tw(500); 344 ze(500); 345 on(500); 346 ni(500); 347 ze(500); 348 ni(500); 349 on(500); 350 fo(500); 351 fi(500); 352 si(500); 353 fo(500); 354 ei(500); 355 fi(500); 356 si(500); 357 si(500); 358 ni(500); 359 tw(500); 360 th(500); 361 fo(500); 362 si(500); 363 ze(500); 364 th(500); 365 fo(500); 366 ei(500); 367 si(500); 368 on(500); 369 ze(500); 370 fo(500); 371 fi(500); 372 fo(500); 373 th(500); 374 tw(500); 375 si(500); 376 si(500); 377 fo(500); 378 ei(500); 379 tw(500); 380 on(500); 381 th(500); 382 th(500); 383 ni(500); 384 th(500); 385 si(500); 386 ze(500); 387 se(500); 388 tw(500); 389 si(500); 390 ze(500); 391 tw(500); 392 fo(500); 393 ni(500); 394 on(500); 395 fo(500); 396 on(500); 397 tw(500); 398 se(500); 399 th(500); 400 se(500); 401 tw(500); 402 fo(500); 403 fi(500); 404 ei(500); 405 se(500); 406 ze(500); 407 ze(500); 408 si(500); 409 si(500); 410 ze(500); 411 si(500); 412 th(500); 413 on(500); 414 fi(500); 415 fi(500); 416 ei(500); 417 ei(500); 418 on(500); 419 se(500); 420 fo(500); 421 ei(500); 422 ei(500); 423 on(500); 424 fi(500); 425 tw(500); 426 ze(500); 427 ni(500); 428 tw(500); 429 ze(500); 430 ni(500); 431 si(500); 432 tw(500); 433 ei(500); 434 tw(500); 435 ni(500); 436 tw(500); 437 fi(500); 438 fo(500); 439 ze(500); 440 ni(500); 441 on(500); 442 se(500); 443 on(500); 444 fi(500); 445 th(500); 446 si(500); 447 fo(500); 448 th(500); 449 si(500); 450 se(500); 451 ei(500); 452 ni(500); 453 tw(500); 454 fi(500); 455 ni(500); 456 ze(500); 457 th(500); 458 si(500); 459 ze(500); 460 ze(500); 461 on(500); 462 on(500); 463 th(500); 464 th(500); 465 ze(500); 466 fi(500); 467 th(500); 468 ze(500); 469 fi(500); 470 fo(500); 471 ei(500); 472 ei(500); 473 tw(500); 474 ze(500); 475 fo(500); 476 si(500); 477 si(500); 478 fi(500); 479 tw(500); 480 on(500); 481 th(500); 482 ei(500); 483 fo(500); 484 on(500); 485 fo(500); 486 si(500); 487 ni(500); 488 fi(500); 489 on(500); 490 ni(500); 491 fo(500); 492 on(500); 493 fi(500); 494 on(500); 495 on(500); 496 si(500); 497 ze(500); 498 ni(500); 499 fo(500); 500 th(500); 501 th(500); 502 ze(500); 503 fi(500); 504 se(500); 505 tw(500); 506 se(500); 507 ze(500); 508 th(500); 509 si(500); 510 fi(500); 511 se(500); 512 fi(500); 513 ni(500); 514 fi(500); 515 ni(500); 516 on(500); 517 ni(500); 518 fi(500); 519 th(500); 520 ze(500); 521 ni(500); 522 tw(500); 523 on(500); 524 ei(500); 525 si(500); 526 on(500); 527 on(500); 528 se(500); 529 th(500); 530 ei(500); 531 on(500); 532 ni(500); 533 th(500); 534 tw(500); 535 si(500); 536 on(500); 537 on(500); 538 se(500); 539 ni(500); 540 th(500); 541 on(500); 542 ze(500); 543 fi(500); 544 on(500); 545 on(500); 546 ei(500); 547 fi(500); 548 fo(500); 549 ei(500); 550 ze(500); 551 se(500); 552 fo(500); 553 fo(500); 554 si(500); 555 tw(500); 556 th(500); 557 se(500); 558 ni(500); 559 ni(500); 560 si(500); 561 tw(500); 562 se(500); 563 fo(500); 564 ni(500); 565 fi(500); 566 si(500); 567 se(500); 568 th(500); 569 fi(500); 570 on(500); 571 ei(500); 572 ei(500); 573 fi(500); 574 se(500); 575 fi(500); 576 tw(500); 577 se(500); 578 tw(500); 579 fo(500); 580 ei(500); 581 ni(500); 582 on(500); 583 tw(500); 584 tw(500); 585 se(500); 586 ni(500); 587 th(500); 588 ei(500); 589 on(500); 590 ei(500); 591 th(500); 592 ze(500); 593 on(500); 594 on(500); 595 ni(500); 596 fo(500); 597 ni(500); 598 on(500); 599 tw(500); 600 ni(500); 601 ei(500); 602 th(500); 603 th(500); 604 si(500); 605 se(500); 606 th(500); 607 th(500); 608 si(500); 609 tw(500); 610 fo(500); 611 fo(500); 612 ze(500); 613 si(500); 614 fi(500); 615 si(500); 616 si(500); 617 fo(500); 618 th(500); 619 ze(500); 620 ei(500); 621 si(500); 622 ze(500); 623 tw(500); 624 on(500); 625 th(500); 626 ni(500); 627 fo(500); 628 ni(500); 629 fo(500); 630 si(500); 631 th(500); 632 ni(500); 633 fi(500); 634 tw(500); 635 tw(500); 636 fo(500); 637 se(500); 638 th(500); 639 se(500); 640 on(500); 641 ni(500); 642 ze(500); 643 se(500); 644 ze(500); 645 tw(500); 646 on(500); 647 se(500); 648 ni(500); 649 ei(500); 650 si(500); 651 ze(500); 652 ni(500); 653 fo(500); 654 th(500); 655 se(500); 656 ze(500); 657 tw(500); 658 se(500); 659 se(500); 660 ze(500); 661 fi(500); 662 th(500); 663 ni(500); 664 tw(500); 665 on(500); 666 se(500); 667 on(500); 668 se(500); 669 si(500); 670 tw(500); 671 ni(500); 672 th(500); 673 on(500); 674 se(500); 675 si(500); 676 se(500); 677 fi(500); 678 tw(500); 679 th(500); 680 ei(500); 681 fo(500); 682 si(500); 683 se(500); 684 fo(500); 685 ei(500); 686 on(500); 687 ei(500); 688 fo(500); 689 si(500); 690 se(500); 691 si(500); 692 si(500); 693 ni(500); 694 fo(500); 695 ze(500); 696 fi(500); 697 on(500); 698 th(500); 699 tw(500); 700 ze(500); 701 ze(500); 702 ze(500); 703 fi(500); 704 si(500); 705 ei(500); 706 on(500); 707 tw(500); 708 se(500); 709 on(500); 710 fo(500); 711 fi(500); 712 tw(500); 713 si(500); 714 th(500); 715 fi(500); 716 si(500); 717 ze(500); 718 ei(500); 719 tw(500); 720 se(500); 721 se(500); 722 ei(500); 723 fi(500); 724 se(500); 725 se(500); 726 on(500); 727 th(500); 728 fo(500); 729 tw(500); 730 se(500); 731 fi(500); 732 se(500); 733 se(500); 734 ei(500); 735 ni(500); 736 si(500); 737 ze(500); 738 ni(500); 739 on(500); 740 se(500); 741 th(500); 742 si(500); 743 th(500); 744 se(500); 745 on(500); 746 se(500); 747 ei(500); 748 se(500); 749 tw(500); 750 on(500); 751 fo(500); 752 si(500); 753 ei(500); 754 fo(500); 755 fo(500); 756 ze(500); 757 ni(500); 758 ze(500); 759 on(500); 760 tw(500); 761 tw(500); 762 fo(500); 763 ni(500); 764 fi(500); 765 th(500); 766 fo(500); 767 th(500); 768 ze(500); 769 on(500); 770 fo(500); 771 si(500); 772 fi(500); 773 fo(500); 774 ni(500); 775 fi(500); 776 ei(500); 777 fi(500); 778 th(500); 779 se(500); 780 on(500); 781 ze(500); 782 fi(500); 783 ze(500); 784 se(500); 785 ni(500); 786 tw(500); 787 tw(500); 788 se(500); 789 ni(500); 790 si(500); 791 ei(500); 792 ni(500); 793 tw(500); 794 fi(500); 795 ei(500); 796 ni(500); 797 tw(500); 798 th(500); 799 fi(500); 800 fo(500); 801 tw(500); 802 ze(500); 803 on(500); 804 ni(500); 805 ni(500); 806 fi(500); 807 si(500); 808 on(500); 809 on(500); 810 tw(500); 811 on(500); 812 tw(500); 813 ni(500); 814 ze(500); 815 tw(500); 816 on(500); 817 ni(500); 818 si(500); 819 ze(500); 820 ei(500); 821 si(500); 822 fo(500); 823 ze(500); 824 th(500); 825 fo(500); 826 fo(500); 827 on(500); 828 ei(500); 829 on(500); 830 fi(500); 831 ni(500); 832 ei(500); 833 on(500); 834 th(500); 835 si(500); 836 tw(500); 837 ni(500); 838 se(500); 839 se(500); 840 fo(500); 841 se(500); 842 se(500); 843 on(500); 844 th(500); 845 ze(500); 846 ni(500); 847 ni(500); 848 si(500); 849 ze(500); 850 fi(500); 851 on(500); 852 ei(500); 853 se(500); 854 ze(500); 855 se(500); 856 tw(500); 857 on(500); 858 on(500); 859 th(500); 860 fo(500); 861 ni(500); 862 ni(500); 863 ni(500); 864 ni(500); 865 ni(500); 866 ni(500); 867 ei(500); 868 th(500); 869 se(500); 870 tw(500); 871 ni(500); 872 se(500); 873 ei(500); 874 ze(500); 875 fo(500); 876 ni(500); 877 ni(500); 878 fi(500); 879 on(500); 880 ze(500); 881 fi(500); 882 ni(500); 883 se(500); 884 th(500); 885 on(500); 886 se(500); 887 th(500); 888 tw(500); 889 ei(500); 890 on(500); 891 si(500); 892 ze(500); 893 ni(500); 894 si(500); 895 th(500); 896 on(500); 897 ei(500); 898 fi(500); 899 ni(500); 900 fi(500); 901 ze(500); 902 tw(500); 903 fo(500); 904 fo(500); 905 fi(500); 906 ni(500); 907 fo(500); 908 fi(500); 909 fi(500); 910 th(500); 911 fo(500); 912 si(500); 913 ni(500); 914 ze(500); 915 ei(500); 916 th(500); 917 ze(500); 918 tw(500); 919 si(500); 920 fo(500); 921 tw(500); 922 fi(500); 923 tw(500); 924 tw(500); 925 th(500); 926 ze(500); 927 ei(500); 928 tw(500); 929 fi(500); 930 th(500); 931 th(500); 932 fo(500); 933 fo(500); 934 si(500); 935 ei(500); 936 fi(500); 937 ze(500); 938 th(500); 939 fi(500); 940 tw(500); 941 si(500); 942 on(500); 943 ni(500); 944 th(500); 945 on(500); 946 on(500); 947 ei(500); 948 ei(500); 949 on(500); 950 se(500); 951 on(500); 952 ze(500); 953 on(500); 954 ze(500); 955 ze(500); 956 ze(500); 957 th(500); 958 on(500); 959 th(500); 960 se(500); 961 ei(500); 962 th(500); 963 ei(500); 964 se(500); 965 fi(500); 966 tw(500); 967 ei(500); 968 ei(500); 969 si(500); 970 fi(500); 971 ei(500); 972 se(500); 973 fi(500); 974 th(500); 975 th(500); 976 tw(500); 977 ze(500); 978 ei(500); 979 th(500); 980 ei(500); 981 on(500); 982 fo(500); 983 tw(500); 984 ze(500); 985 si(500); 986 on(500); 987 se(500); 988 on(500); 989 se(500); 990 se(500); 991 si(500); 992 si(500); 993 ni(500); 994 on(500); 995 fo(500); 996 se(500); 997 th(500); 998 ze(500); 999 th(500); 1000 fi(500); 1001 delay(5000); 1002} 1003
Comments
Only logged in users can leave comments
Dcspeiser
0 Followers
•0 Projects
Table of contents
Intro
0
0