Components and supplies
WS2812 5050 8x8 Matrix
Arduino Nano R3
Apps and platforms
Arduino IDE
Project description
Code
Fade out Transition
arduino
Each displayed digit is fading out before next digit is displayed
1// MARIO's IDEAS 2// "Final Countdown" on WS2812 Matrix 3// Fade transition transition 4// After displaying the digit we decrease the brightness until the digit fades out. 5// The next digit is displayed with full brightness and the process get repeated. 6 7 8#include <FastLED.h> 9 10// Variables to store the current digit we . We start with 9 11int Current_Digit=9; 12 13 14//A selection of colors we randommly choose from to define the color of the outline of the digit 15uint16_t Colors [27]{0x7FFF00,0x6495ED,0xDC143,0x00008B,0x8B008B, 16 0xFF8C00,0x00CED1,0x9400D3,0xFF1493,0x228B22, 17 0xFFD700,0xADFF2F,0x7CFC00,0x87CEFA,0x00FF00, 18 0xFF00FF,0x0000CD,0xFFA500,0x9ACD32,0xFFE4C4, 19 0x00FFFF,0x008B8B,0xE9967A,0xFFFACD,0xADD8E6, 20 0xFAFAD2,0xFFEFD5}; 21// Variables used to store the colors. They store the index of the color in the Colors array 22int Current_Color=1; // color of the outline of the current digit 23int Random_Color=2; //used for random color generation 24 25// How many leds in your strip? 26#define NUM_LEDS 64 27 28// For led chips like Neopixels, which have a data line, ground, and power, you just 29// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, 30// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN 31#define DATA_PIN 5 32 33 34// Define the array of leds 35CRGB leds[NUM_LEDS]; 36 37 38// 8x8 Arrays ZERO to NINE defining the layout of pixels in each digit. 0- blank pixel, 1 - the digit pixel, 2 - the outline pixel 39 40int One [8] [8] ={ 41 {0,0,0,0,1,2,0,0}, 42 {0,0,0,1,1,2,0,0}, 43 {0,0,1,2,1,2,0,0}, 44 {0,1,2,0,1,2,0,0}, 45 {0,0,0,0,1,2,0,0}, 46 {0,0,0,0,1,2,0,0}, 47 {0,0,0,0,1,2,0,0}, 48 {0,0,0,0,1,2,0,0}, 49}; 50int Two [8] [8] ={ 51 {0,0,1,1,1,2,0,0}, 52 {0,1,2,0,0,1,2,0}, 53 {0,0,0,0,0,1,2,0}, 54 {0,0,0,0,1,2,0,0}, 55 {0,0,0,1,2,0,0,0}, 56 {0,0,1,2,0,0,0,0}, 57 {0,1,2,0,0,0,0,0}, 58 {0,1,1,1,1,1,2,0}, 59}; 60int Three [8] [8] ={ 61 {0,0,1,1,1,2,0,0}, 62 {0,1,2,0,0,1,2,0}, 63 {0,0,0,0,0,1,2,0}, 64 {0,0,0,1,1,2,0,0}, 65 {0,0,0,0,0,1,2,0}, 66 {0,0,0,0,0,1,2,0}, 67 {0,1,2,0,0,1,2,0}, 68 {0,0,1,1,1,2,0,0}, 69}; 70int Four [8] [8] ={ 71 {0,0,0,0,1,2,0,0}, 72 {0,0,0,1,1,2,0,0}, 73 {0,0,1,2,1,2,0,0}, 74 {0,1,2 ,0,1,2,0,0}, 75 {0,1,1,1,1,1,2,0}, 76 {0,0,0,0,1,2,0,0}, 77 {0,0,0,0,1,2,0,0}, 78 {0,0,0,0,1,2,0,0}, 79}; 80int Five [8] [8] ={ 81 {0,1,1,1,1,1,2,0}, 82 {0,1,2,0,0,0,0,0}, 83 {0,1,2,0,0,0,0,0}, 84 {0,0,1,1,1,2,0,0}, 85 {0,0,0,0,0,1,2,0}, 86 {0,0,0,0,0,1,2,0}, 87 {0,1,2,0,0,1,2,0}, 88 {0,0,1,1,1,2,0,0}, 89}; 90 91 92int Six [8] [8] ={ 93 {0,0,1,1,1,2,0,0}, 94 {0,1,2,0,0,1,2,0}, 95 {0,1,2,0,0,0,0,0}, 96 {0,1,1,1,1,2,0,0}, 97 {0,1,2,0,0,1,2,0}, 98 {0,1,2,0,0,1,2,0}, 99 {0,1,2,0,0,1,2,0}, 100 {0,0,1,1,1,2,0,0}, 101}; 102 103int Seven [8] [8] ={ 104 {0,1,1,1,1,1,2,0}, 105 {0,0,0,0,0,1,2,0}, 106 {0,0,0,0,0,1,2,0}, 107 {0,0,0,0,1,2,0,0}, 108 {0,0,0,1,2,0,0,0}, 109 {0,0,1,2,0,0,0,0}, 110 {0,0,1,2,0,0,0,0}, 111 {0,0,1,2,0,0,0,0}, 112}; 113 114int Eight [8] [8] ={ 115 {0,0,1,1,1,2,0,0}, 116 {0,1,2,0,0,1,2,0}, 117 {0,1,2,0,0,1,2,0}, 118 {0,0,1,1,1,2,0,0}, 119 {0,1,2,0,0,1,2,0}, 120 {0,1,2,0,0,1,2,0}, 121 {0,1,2,0,0,1,2,0}, 122 {0,0,1,1,1,2,0,0}, 123}; 124 125int Nine [8] [8] ={ 126 {0,0,1,1,1,2,0,0}, 127 {0,1,2,0,0,1,2,0}, 128 {0,1,2,0,0,1,2,0}, 129 {0,0,1,1,1,1,2,0}, 130 {0,0,0,0,0,1,2,0}, 131 {0,0,0,0,0,1,2,0}, 132 {0,1,2,0,0,1,2,0}, 133 {0,0,1,1,1,2,0,0}, 134}; 135int Zero [8] [8] ={ 136 {0,0,1,1,1,2,0,0}, 137 {0,1,2,0,0,1,2,0}, 138 {0,1,2,0,0,1,2,0}, 139 {0,1,2,0,0,1,2,0}, 140 {0,1,2,0,0,1,2,0}, 141 {0,1,2,0,0,1,2,0}, 142 {0,1,2,0,0,1,2,0}, 143 {0,0,1,1,1,2,0,0}, 144}; 145 146 147void setup() { 148 Serial.begin(9600); 149 Serial.println("resetting"); 150 // Declaring the matrix and setting the LED brightness 151 LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS); 152 LEDS.setBrightness(84); 153 154} 155 156// function to check which type of pixel (0,1 or 2) we have in coordinates i,j in the array corresponding to digit passed by argument Number 157int Check_Pixel_In_Digit(int Number, int i,int j){ 158int result; 159 if (Number ==0) result=Zero[i][j]; 160 if (Number ==1) result=One[i][j]; 161 if (Number ==2) result=Two[i][j]; 162 if (Number ==3) result=Three[i][j]; 163 if (Number ==4) result=Four[i][j]; 164 if (Number ==5) result=Five[i][j]; 165 if (Number ==6) result=Six[i][j]; 166 if (Number ==7) result=Seven[i][j]; 167 if (Number ==8) result=Eight[i][j]; 168 if (Number ==9) result=Nine[i][j]; 169 return result; 170 171} 172 173void loop() { 174 175// Setting the Brightness LEDs to fully lit 176 177LEDS.setBrightness(84); 178 179// displaying the digit corresponding to value stored in Current_Digit 180 181 for (int i=0;i<8;i++){ 182 for (int j=0;j<8;j++){ 183 if (Check_Pixel_In_Digit(Current_Digit,i,j)==1) leds[(i)*8+j]=CHSV( 0 , 0, 255); 184 if (Check_Pixel_In_Digit(Current_Digit,i,j)==2) leds[(i)*8+j]=Colors[Current_Color]; 185 if (Check_Pixel_In_Digit(Current_Digit,i,j)==0) leds[(i)*8+j]=CHSV( 0 , 0, 0); 186 } 187 } 188 189// Gradually decrease the brightnes of currently lit LEDs 190 for(int i=84;i>0;i--){ 191 LEDS.setBrightness(i); 192 FastLED.show(); 193 delay(15); 194} 195delay(300); 196 197// Decrease current digit by one 198Current_Digit=Current_Digit-1; 199 200 201// Generate the outline color for the next digit and making sure it is going to be a different one each time 202 203while (Random_Color==Current_Color){ 204 Random_Color=random(0,27); 205} 206Current_Color=Random_Color; 207 208// if zero is reached we start the countdown again from 9 209if (Current_Digit==-1){ 210 Current_Digit=9; 211} 212 213}
Basics transition
arduino
Displays one digit after the other
1// MARIO's IDEAS 2// "Final Countdown" on WS2812 Matrix 3// Basic digit to digit transition 4 5 6#include <FastLED.h> 7 8// Variables to store the current digit. We start with 9 9int Current_Digit=9; 10 11 12//A selection of colors we randommly choose from to define the color of the outline of the digit 13uint16_t Colors [27]{0x7FFF00,0x6495ED,0xDC143,0x00008B,0x8B008B, 14 0xFF8C00,0x00CED1,0x9400D3,0xFF1493,0x228B22, 15 0xFFD700,0xADFF2F,0x7CFC00,0x87CEFA,0x00FF00, 16 0xFF00FF,0x0000CD,0xFFA500,0x9ACD32,0xFFE4C4, 17 0x00FFFF,0x008B8B,0xE9967A,0xFFFACD,0xADD8E6, 18 0xFAFAD2,0xFFEFD5}; 19// Variables used to store the colors. They store the index of the color in the Colors arraay 20int Current_Color=1; // color of the outline of the current digit 21int Random_Color=2; //used for random color generation 22 23// How many leds in your strip? 24#define NUM_LEDS 64 25 26// For led chips like Neopixels, which have a data line, ground, and power, you just 27// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, 28// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN 29#define DATA_PIN 5 30 31 32// Define the array of leds 33CRGB leds[NUM_LEDS]; 34 35 36// 8x8 Arrays ZERO to NINE defining the layout of pixels in each digit. 0- blank pixel, 1 - the digit pixel, 2 - the outline pixel 37 38int One [8] [8] ={ 39 {0,0,0,0,1,2,0,0}, 40 {0,0,0,1,1,2,0,0}, 41 {0,0,1,2,1,2,0,0}, 42 {0,1,2,0,1,2,0,0}, 43 {0,0,0,0,1,2,0,0}, 44 {0,0,0,0,1,2,0,0}, 45 {0,0,0,0,1,2,0,0}, 46 {0,0,0,0,1,2,0,0}, 47}; 48int Two [8] [8] ={ 49 {0,0,1,1,1,2,0,0}, 50 {0,1,2,0,0,1,2,0}, 51 {0,0,0,0,0,1,2,0}, 52 {0,0,0,0,1,2,0,0}, 53 {0,0,0,1,2,0,0,0}, 54 {0,0,1,2,0,0,0,0}, 55 {0,1,2,0,0,0,0,0}, 56 {0,1,1,1,1,1,2,0}, 57}; 58int Three [8] [8] ={ 59 {0,0,1,1,1,2,0,0}, 60 {0,1,2,0,0,1,2,0}, 61 {0,0,0,0,0,1,2,0}, 62 {0,0,0,1,1,2,0,0}, 63 {0,0,0,0,0,1,2,0}, 64 {0,0,0,0,0,1,2,0}, 65 {0,1,2,0,0,1,2,0}, 66 {0,0,1,1,1,2,0,0}, 67}; 68int Four [8] [8] ={ 69 {0,0,0,0,1,2,0,0}, 70 {0,0,0,1,1,2,0,0}, 71 {0,0,1,2,1,2,0,0}, 72 {0,1,2 ,0,1,2,0,0}, 73 {0,1,1,1,1,1,2,0}, 74 {0,0,0,0,1,2,0,0}, 75 {0,0,0,0,1,2,0,0}, 76 {0,0,0,0,1,2,0,0}, 77}; 78int Five [8] [8] ={ 79 {0,1,1,1,1,1,2,0}, 80 {0,1,2,0,0,0,0,0}, 81 {0,1,2,0,0,0,0,0}, 82 {0,0,1,1,1,2,0,0}, 83 {0,0,0,0,0,1,2,0}, 84 {0,0,0,0,0,1,2,0}, 85 {0,1,2,0,0,1,2,0}, 86 {0,0,1,1,1,2,0,0}, 87}; 88 89 90int Six [8] [8] ={ 91 {0,0,1,1,1,2,0,0}, 92 {0,1,2,0,0,1,2,0}, 93 {0,1,2,0,0,0,0,0}, 94 {0,1,1,1,1,2,0,0}, 95 {0,1,2,0,0,1,2,0}, 96 {0,1,2,0,0,1,2,0}, 97 {0,1,2,0,0,1,2,0}, 98 {0,0,1,1,1,2,0,0}, 99}; 100 101int Seven [8] [8] ={ 102 {0,1,1,1,1,1,2,0}, 103 {0,0,0,0,0,1,2,0}, 104 {0,0,0,0,0,1,2,0}, 105 {0,0,0,0,1,2,0,0}, 106 {0,0,0,1,2,0,0,0}, 107 {0,0,1,2,0,0,0,0}, 108 {0,0,1,2,0,0,0,0}, 109 {0,0,1,2,0,0,0,0}, 110}; 111 112int Eight [8] [8] ={ 113 {0,0,1,1,1,2,0,0}, 114 {0,1,2,0,0,1,2,0}, 115 {0,1,2,0,0,1,2,0}, 116 {0,0,1,1,1,2,0,0}, 117 {0,1,2,0,0,1,2,0}, 118 {0,1,2,0,0,1,2,0}, 119 {0,1,2,0,0,1,2,0}, 120 {0,0,1,1,1,2,0,0}, 121}; 122 123int Nine [8] [8] ={ 124 {0,0,1,1,1,2,0,0}, 125 {0,1,2,0,0,1,2,0}, 126 {0,1,2,0,0,1,2,0}, 127 {0,0,1,1,1,1,2,0}, 128 {0,0,0,0,0,1,2,0}, 129 {0,0,0,0,0,1,2,0}, 130 {0,1,2,0,0,1,2,0}, 131 {0,0,1,1,1,2,0,0}, 132}; 133int Zero [8] [8] ={ 134 {0,0,1,1,1,2,0,0}, 135 {0,1,2,0,0,1,2,0}, 136 {0,1,2,0,0,1,2,0}, 137 {0,1,2,0,0,1,2,0}, 138 {0,1,2,0,0,1,2,0}, 139 {0,1,2,0,0,1,2,0}, 140 {0,1,2,0,0,1,2,0}, 141 {0,0,1,1,1,2,0,0}, 142}; 143 144 145void setup() { 146 Serial.begin(9600); 147 Serial.println("resetting"); 148 // Declaring the matrix and setting the LED brightness 149 LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS); 150 LEDS.setBrightness(84); 151 152} 153 154// function to check which type of pixel (0,1 or 2) we have in coordinates i,j in the array corresponding to digit passed by argument Number 155int Check_Pixel_In_Digit(int Number, int i,int j){ 156int result; 157 if (Number ==0) result=Zero[i][j]; 158 if (Number ==1) result=One[i][j]; 159 if (Number ==2) result=Two[i][j]; 160 if (Number ==3) result=Three[i][j]; 161 if (Number ==4) result=Four[i][j]; 162 if (Number ==5) result=Five[i][j]; 163 if (Number ==6) result=Six[i][j]; 164 if (Number ==7) result=Seven[i][j]; 165 if (Number ==8) result=Eight[i][j]; 166 if (Number ==9) result=Nine[i][j]; 167 return result; 168 169} 170 171void loop() { 172 173// displaying the digit corresponding to value stored in Current_Digit 174 175 for (int i=0;i<8;i++){ 176 for (int j=0;j<8;j++){ 177 if (Check_Pixel_In_Digit(Current_Digit,i,j)==1) leds[(i)*8+j]=CHSV( 0 , 0, 255); 178 if (Check_Pixel_In_Digit(Current_Digit,i,j)==2) leds[(i)*8+j]=Colors[Current_Color]; 179 if (Check_Pixel_In_Digit(Current_Digit,i,j)==0) leds[(i)*8+j]=CHSV( 0 , 0, 0); 180 } 181 } 182// Displaying all 64 LEDs in their current state 183FastLED.show(); 184delay(500); 185 186// Decreasing current digit by one 187Current_Digit=Current_Digit-1; 188 189 190// Generate the outline color for the next digit and making sure it is going to be a different one each time 191 192while (Random_Color==Current_Color){ 193 Random_Color=random(0,27); 194} 195Current_Color=Random_Color; 196 197if (Current_Digit==-1){ 198 Current_Digit=9; 199} 200 201}
Fade out Transition
arduino
Each displayed digit is fading out before next digit is displayed
1// MARIO's IDEAS 2// "Final Countdown" on WS2812 Matrix 3// Fade transition transition 4// After displaying the digit we decrease the brightness until the digit fades out. 5// The next digit is displayed with full brightness and the process get repeated. 6 7 8#include <FastLED.h> 9 10// Variables to store the current digit we . We start with 9 11int Current_Digit=9; 12 13 14//A selection of colors we randommly choose from to define the color of the outline of the digit 15uint16_t Colors [27]{0x7FFF00,0x6495ED,0xDC143,0x00008B,0x8B008B, 16 0xFF8C00,0x00CED1,0x9400D3,0xFF1493,0x228B22, 17 0xFFD700,0xADFF2F,0x7CFC00,0x87CEFA,0x00FF00, 18 0xFF00FF,0x0000CD,0xFFA500,0x9ACD32,0xFFE4C4, 19 0x00FFFF,0x008B8B,0xE9967A,0xFFFACD,0xADD8E6, 20 0xFAFAD2,0xFFEFD5}; 21// Variables used to store the colors. They store the index of the color in the Colors array 22int Current_Color=1; // color of the outline of the current digit 23int Random_Color=2; //used for random color generation 24 25// How many leds in your strip? 26#define NUM_LEDS 64 27 28// For led chips like Neopixels, which have a data line, ground, and power, you just 29// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, 30// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN 31#define DATA_PIN 5 32 33 34// Define the array of leds 35CRGB leds[NUM_LEDS]; 36 37 38// 8x8 Arrays ZERO to NINE defining the layout of pixels in each digit. 0- blank pixel, 1 - the digit pixel, 2 - the outline pixel 39 40int One [8] [8] ={ 41 {0,0,0,0,1,2,0,0}, 42 {0,0,0,1,1,2,0,0}, 43 {0,0,1,2,1,2,0,0}, 44 {0,1,2,0,1,2,0,0}, 45 {0,0,0,0,1,2,0,0}, 46 {0,0,0,0,1,2,0,0}, 47 {0,0,0,0,1,2,0,0}, 48 {0,0,0,0,1,2,0,0}, 49}; 50int Two [8] [8] ={ 51 {0,0,1,1,1,2,0,0}, 52 {0,1,2,0,0,1,2,0}, 53 {0,0,0,0,0,1,2,0}, 54 {0,0,0,0,1,2,0,0}, 55 {0,0,0,1,2,0,0,0}, 56 {0,0,1,2,0,0,0,0}, 57 {0,1,2,0,0,0,0,0}, 58 {0,1,1,1,1,1,2,0}, 59}; 60int Three [8] [8] ={ 61 {0,0,1,1,1,2,0,0}, 62 {0,1,2,0,0,1,2,0}, 63 {0,0,0,0,0,1,2,0}, 64 {0,0,0,1,1,2,0,0}, 65 {0,0,0,0,0,1,2,0}, 66 {0,0,0,0,0,1,2,0}, 67 {0,1,2,0,0,1,2,0}, 68 {0,0,1,1,1,2,0,0}, 69}; 70int Four [8] [8] ={ 71 {0,0,0,0,1,2,0,0}, 72 {0,0,0,1,1,2,0,0}, 73 {0,0,1,2,1,2,0,0}, 74 {0,1,2 ,0,1,2,0,0}, 75 {0,1,1,1,1,1,2,0}, 76 {0,0,0,0,1,2,0,0}, 77 {0,0,0,0,1,2,0,0}, 78 {0,0,0,0,1,2,0,0}, 79}; 80int Five [8] [8] ={ 81 {0,1,1,1,1,1,2,0}, 82 {0,1,2,0,0,0,0,0}, 83 {0,1,2,0,0,0,0,0}, 84 {0,0,1,1,1,2,0,0}, 85 {0,0,0,0,0,1,2,0}, 86 {0,0,0,0,0,1,2,0}, 87 {0,1,2,0,0,1,2,0}, 88 {0,0,1,1,1,2,0,0}, 89}; 90 91 92int Six [8] [8] ={ 93 {0,0,1,1,1,2,0,0}, 94 {0,1,2,0,0,1,2,0}, 95 {0,1,2,0,0,0,0,0}, 96 {0,1,1,1,1,2,0,0}, 97 {0,1,2,0,0,1,2,0}, 98 {0,1,2,0,0,1,2,0}, 99 {0,1,2,0,0,1,2,0}, 100 {0,0,1,1,1,2,0,0}, 101}; 102 103int Seven [8] [8] ={ 104 {0,1,1,1,1,1,2,0}, 105 {0,0,0,0,0,1,2,0}, 106 {0,0,0,0,0,1,2,0}, 107 {0,0,0,0,1,2,0,0}, 108 {0,0,0,1,2,0,0,0}, 109 {0,0,1,2,0,0,0,0}, 110 {0,0,1,2,0,0,0,0}, 111 {0,0,1,2,0,0,0,0}, 112}; 113 114int Eight [8] [8] ={ 115 {0,0,1,1,1,2,0,0}, 116 {0,1,2,0,0,1,2,0}, 117 {0,1,2,0,0,1,2,0}, 118 {0,0,1,1,1,2,0,0}, 119 {0,1,2,0,0,1,2,0}, 120 {0,1,2,0,0,1,2,0}, 121 {0,1,2,0,0,1,2,0}, 122 {0,0,1,1,1,2,0,0}, 123}; 124 125int Nine [8] [8] ={ 126 {0,0,1,1,1,2,0,0}, 127 {0,1,2,0,0,1,2,0}, 128 {0,1,2,0,0,1,2,0}, 129 {0,0,1,1,1,1,2,0}, 130 {0,0,0,0,0,1,2,0}, 131 {0,0,0,0,0,1,2,0}, 132 {0,1,2,0,0,1,2,0}, 133 {0,0,1,1,1,2,0,0}, 134}; 135int Zero [8] [8] ={ 136 {0,0,1,1,1,2,0,0}, 137 {0,1,2,0,0,1,2,0}, 138 {0,1,2,0,0,1,2,0}, 139 {0,1,2,0,0,1,2,0}, 140 {0,1,2,0,0,1,2,0}, 141 {0,1,2,0,0,1,2,0}, 142 {0,1,2,0,0,1,2,0}, 143 {0,0,1,1,1,2,0,0}, 144}; 145 146 147void setup() { 148 Serial.begin(9600); 149 Serial.println("resetting"); 150 // Declaring the matrix and setting the LED brightness 151 LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS); 152 LEDS.setBrightness(84); 153 154} 155 156// function to check which type of pixel (0,1 or 2) we have in coordinates i,j in the array corresponding to digit passed by argument Number 157int Check_Pixel_In_Digit(int Number, int i,int j){ 158int result; 159 if (Number ==0) result=Zero[i][j]; 160 if (Number ==1) result=One[i][j]; 161 if (Number ==2) result=Two[i][j]; 162 if (Number ==3) result=Three[i][j]; 163 if (Number ==4) result=Four[i][j]; 164 if (Number ==5) result=Five[i][j]; 165 if (Number ==6) result=Six[i][j]; 166 if (Number ==7) result=Seven[i][j]; 167 if (Number ==8) result=Eight[i][j]; 168 if (Number ==9) result=Nine[i][j]; 169 return result; 170 171} 172 173void loop() { 174 175// Setting the Brightness LEDs to fully lit 176 177LEDS.setBrightness(84); 178 179// displaying the digit corresponding to value stored in Current_Digit 180 181 for (int i=0;i<8;i++){ 182 for (int j=0;j<8;j++){ 183 if (Check_Pixel_In_Digit(Current_Digit,i,j)==1) leds[(i)*8+j]=CHSV( 0 , 0, 255); 184 if (Check_Pixel_In_Digit(Current_Digit,i,j)==2) leds[(i)*8+j]=Colors[Current_Color]; 185 if (Check_Pixel_In_Digit(Current_Digit,i,j)==0) leds[(i)*8+j]=CHSV( 0 , 0, 0); 186 } 187 } 188 189// Gradually decrease the brightnes of currently lit LEDs 190 for(int i=84;i>0;i--){ 191 LEDS.setBrightness(i); 192 FastLED.show(); 193 delay(15); 194} 195delay(300); 196 197// Decrease current digit by one 198Current_Digit=Current_Digit-1; 199 200 201// Generate the outline color for the next digit and making sure it is going to be a different one each time 202 203while (Random_Color==Current_Color){ 204 Random_Color=random(0,27); 205} 206Current_Color=Random_Color; 207 208// if zero is reached we start the countdown again from 9 209if (Current_Digit==-1){ 210 Current_Digit=9; 211} 212 213}
Basics transition
arduino
Displays one digit after the other
1// MARIO's IDEAS 2// "Final Countdown" on WS2812 Matrix 3// Basic 4 digit to digit transition 5 6 7#include <FastLED.h> 8 9// Variables to 10 store the current digit. We start with 9 11int Current_Digit=9; 12 13 14//A 15 selection of colors we randommly choose from to define the color of the outline 16 of the digit 17uint16_t Colors [27]{0x7FFF00,0x6495ED,0xDC143,0x00008B,0x8B008B, 18 19 0xFF8C00,0x00CED1,0x9400D3,0xFF1493,0x228B22, 20 0xFFD700,0xADFF2F,0x7CFC00,0x87CEFA,0x00FF00, 21 22 0xFF00FF,0x0000CD,0xFFA500,0x9ACD32,0xFFE4C4, 23 0x00FFFF,0x008B8B,0xE9967A,0xFFFACD,0xADD8E6, 24 25 0xFAFAD2,0xFFEFD5}; 26// Variables used to store the colors. 27 They store the index of the color in the Colors arraay 28int Current_Color=1; // 29 color of the outline of the current digit 30int Random_Color=2; //used for random 31 color generation 32 33// How many leds in your strip? 34#define NUM_LEDS 64 35 36 37// For led chips like Neopixels, which have a data line, ground, and power, 38 you just 39// need to define DATA_PIN. For led chipsets that are SPI based (four 40 wires - data, clock, 41// ground, and power), like the LPD8806, define both DATA_PIN 42 and CLOCK_PIN 43#define DATA_PIN 5 44 45 46// Define the array of leds 47CRGB 48 leds[NUM_LEDS]; 49 50 51// 8x8 Arrays ZERO to NINE defining the layout of pixels 52 in each digit. 0- blank pixel, 1 - the digit pixel, 2 - the outline pixel 53 54int 55 One [8] [8] ={ 56 {0,0,0,0,1,2,0,0}, 57 {0,0,0,1,1,2,0,0}, 58 {0,0,1,2,1,2,0,0}, 59 60 {0,1,2,0,1,2,0,0}, 61 {0,0,0,0,1,2,0,0}, 62 {0,0,0,0,1,2,0,0}, 63 {0,0,0,0,1,2,0,0}, 64 65 {0,0,0,0,1,2,0,0}, 66}; 67int Two [8] [8] ={ 68 {0,0,1,1,1,2,0,0}, 69 {0,1,2,0,0,1,2,0}, 70 71 {0,0,0,0,0,1,2,0}, 72 {0,0,0,0,1,2,0,0}, 73 {0,0,0,1,2,0,0,0}, 74 {0,0,1,2,0,0,0,0}, 75 76 {0,1,2,0,0,0,0,0}, 77 {0,1,1,1,1,1,2,0}, 78}; 79int Three [8] [8] ={ 80 {0,0,1,1,1,2,0,0}, 81 82 {0,1,2,0,0,1,2,0}, 83 {0,0,0,0,0,1,2,0}, 84 {0,0,0,1,1,2,0,0}, 85 {0,0,0,0,0,1,2,0}, 86 87 {0,0,0,0,0,1,2,0}, 88 {0,1,2,0,0,1,2,0}, 89 {0,0,1,1,1,2,0,0}, 90}; 91int 92 Four [8] [8] ={ 93 {0,0,0,0,1,2,0,0}, 94 {0,0,0,1,1,2,0,0}, 95 {0,0,1,2,1,2,0,0}, 96 97 {0,1,2 ,0,1,2,0,0}, 98 {0,1,1,1,1,1,2,0}, 99 {0,0,0,0,1,2,0,0}, 100 {0,0,0,0,1,2,0,0}, 101 102 {0,0,0,0,1,2,0,0}, 103}; 104int Five [8] [8] ={ 105 {0,1,1,1,1,1,2,0}, 106 {0,1,2,0,0,0,0,0}, 107 108 {0,1,2,0,0,0,0,0}, 109 {0,0,1,1,1,2,0,0}, 110 {0,0,0,0,0,1,2,0}, 111 {0,0,0,0,0,1,2,0}, 112 113 {0,1,2,0,0,1,2,0}, 114 {0,0,1,1,1,2,0,0}, 115}; 116 117 118int Six [8] [8] 119 ={ 120 {0,0,1,1,1,2,0,0}, 121 {0,1,2,0,0,1,2,0}, 122 {0,1,2,0,0,0,0,0}, 123 {0,1,1,1,1,2,0,0}, 124 125 {0,1,2,0,0,1,2,0}, 126 {0,1,2,0,0,1,2,0}, 127 {0,1,2,0,0,1,2,0}, 128 {0,0,1,1,1,2,0,0}, 129}; 130 131 132int Seven [8] [8] ={ 133 {0,1,1,1,1,1,2,0}, 134 {0,0,0,0,0,1,2,0}, 135 136 {0,0,0,0,0,1,2,0}, 137 {0,0,0,0,1,2,0,0}, 138 {0,0,0,1,2,0,0,0}, 139 {0,0,1,2,0,0,0,0}, 140 141 {0,0,1,2,0,0,0,0}, 142 {0,0,1,2,0,0,0,0}, 143}; 144 145int Eight [8] [8] ={ 146 147 {0,0,1,1,1,2,0,0}, 148 {0,1,2,0,0,1,2,0}, 149 {0,1,2,0,0,1,2,0}, 150 {0,0,1,1,1,2,0,0}, 151 152 {0,1,2,0,0,1,2,0}, 153 {0,1,2,0,0,1,2,0}, 154 {0,1,2,0,0,1,2,0}, 155 {0,0,1,1,1,2,0,0}, 156}; 157 158 159int Nine [8] [8] ={ 160 {0,0,1,1,1,2,0,0}, 161 {0,1,2,0,0,1,2,0}, 162 163 {0,1,2,0,0,1,2,0}, 164 {0,0,1,1,1,1,2,0}, 165 {0,0,0,0,0,1,2,0}, 166 {0,0,0,0,0,1,2,0}, 167 168 {0,1,2,0,0,1,2,0}, 169 {0,0,1,1,1,2,0,0}, 170}; 171int Zero [8] [8] ={ 172 173 {0,0,1,1,1,2,0,0}, 174 {0,1,2,0,0,1,2,0}, 175 {0,1,2,0,0,1,2,0}, 176 {0,1,2,0,0,1,2,0}, 177 178 {0,1,2,0,0,1,2,0}, 179 {0,1,2,0,0,1,2,0}, 180 {0,1,2,0,0,1,2,0}, 181 {0,0,1,1,1,2,0,0}, 182}; 183 184 185 186void setup() { 187 Serial.begin(9600); 188 Serial.println("resetting"); 189 // 190 Declaring the matrix and setting the LED brightness 191 LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS); 192 LEDS.setBrightness(84); 193 194 195} 196 197// function to check which type of pixel (0,1 or 2) we have in coordinates 198 i,j in the array corresponding to digit passed by argument Number 199int Check_Pixel_In_Digit(int 200 Number, int i,int j){ 201int result; 202 if (Number ==0) result=Zero[i][j]; 203 204 if (Number ==1) result=One[i][j]; 205 if (Number ==2) result=Two[i][j]; 206 if (Number 207 ==3) result=Three[i][j]; 208 if (Number ==4) result=Four[i][j]; 209 if (Number ==5) 210 result=Five[i][j]; 211 if (Number ==6) result=Six[i][j]; 212 if (Number ==7) result=Seven[i][j]; 213 214 if (Number ==8) result=Eight[i][j]; 215 if (Number ==9) result=Nine[i][j]; 216 return 217 result; 218 219} 220 221void loop() { 222 223// displaying the digit corresponding 224 to value stored in Current_Digit 225 226 for (int i=0;i<8;i++){ 227 for (int 228 j=0;j<8;j++){ 229 if (Check_Pixel_In_Digit(Current_Digit,i,j)==1) leds[(i)*8+j]=CHSV( 230 0 , 0, 255); 231 if (Check_Pixel_In_Digit(Current_Digit,i,j)==2) leds[(i)*8+j]=Colors[Current_Color]; 232 233 if (Check_Pixel_In_Digit(Current_Digit,i,j)==0) leds[(i)*8+j]=CHSV( 0 , 0, 0); 234 235 } 236 } 237// Displaying all 64 LEDs in their current state 238FastLED.show(); 239delay(500); 240 241// 242 Decreasing current digit by one 243Current_Digit=Current_Digit-1; 244 245 246// 247 Generate the outline color for the next digit and making sure it is going to be 248 a different one each time 249 250while (Random_Color==Current_Color){ 251 Random_Color=random(0,27); 252} 253Current_Color=Random_Color; 254 255if 256 (Current_Digit==-1){ 257 Current_Digit=9; 258} 259 260}
Color Blur Transition
arduino
Randomly select pixels and set them to random colors. Then randomly select pixels and send them to color corresponding with tarhet digit
1// MARIO's IDEAS 2// "Final Countdown" on WS2812 Matrix 3// Color 4 Blur transition 5// After displaying the digit randomly select pixels and lit 6 them with random colors 7// Then we randomly select pixels and set them to the 8 colors that correspond with next digit to display 9 10#include <FastLED.h> 11 12// 13 Variables to store the current digit we . We start with 9 14int Current_Digit=9; 15int 16 led_x; 17int led_y; 18 19//A selection of colors we randommly choose from to 20 define the color of the outline of the digit 21uint16_t Colors [27]{0x7FFF00,0x6495ED,0xDC143,0x00008B,0x8B008B,0xFF8C00,0x00CED1,0x9400D3, 22 23 0xFF1493,0x228B22,0xFFD700,0xADFF2F,0x7CFC00,0x87CEFA,0x00FF00,0xFF00FF, 24 25 0x0000CD,0xFFA500,0x9ACD32,0xFFE4C4,0x00FFFF,0x008B8B,0xE9967A,0xFFFACD,0xADD8E6,0xFAFAD2,0xFFEFD5}; 26 27// 28 Variables used to store the colors. They store the index of the color in the Colors 29 array 30int Current_Color=1;// color of the outline of the current digit 31int 32 Random_Color=2;//used for random color generation 33 34 35// How many leds in 36 your strip? 37#define NUM_LEDS 64 38 39// For led chips like Neopixels, which 40 have a data line, ground, and power, you just 41// need to define DATA_PIN. For 42 led chipsets that are SPI based (four wires - data, clock, 43// ground, and power), 44 like the LPD8806, define both DATA_PIN and CLOCK_PIN 45#define DATA_PIN 5 46 47// 48 Define the array of leds 49CRGB leds[NUM_LEDS]; 50 51// 8x8 Arrays ZERO to NINE 52 defining the layout of pixels in each digit. 0- blank pixel, 1 - the digit pixel, 53 2 - the outline pixel 54 55int One [8] [8] ={ 56 {0,0,0,0,1,2,0,0}, 57 {0,0,0,1,1,2,0,0}, 58 59 {0,0,1,2,1,2,0,0}, 60 {0,1,2,0,1,2,0,0}, 61 {0,0,0,0,1,2,0,0}, 62 {0,0,0,0,1,2,0,0}, 63 64 {0,0,0,0,1,2,0,0}, 65 {0,0,0,0,1,2,0,0}, 66}; 67int Two [8] [8] ={ 68 {0,0,1,1,1,2,0,0}, 69 70 {0,1,2,0,0,1,2,0}, 71 {0,0,0,0,0,1,2,0}, 72 {0,0,0,0,1,2,0,0}, 73 {0,0,0,1,2,0,0,0}, 74 75 {0,0,1,2,0,0,0,0}, 76 {0,1,2,0,0,0,0,0}, 77 {0,1,1,1,1,1,2,0}, 78}; 79int 80 Three [8] [8] ={ 81 {0,0,1,1,1,2,0,0}, 82 {0,1,2,0,0,1,2,0}, 83 {0,0,0,0,0,1,2,0}, 84 85 {0,0,0,1,1,2,0,0}, 86 {0,0,0,0,0,1,2,0}, 87 {0,0,0,0,0,1,2,0}, 88 {0,1,2,0,0,1,2,0}, 89 90 {0,0,1,1,1,2,0,0}, 91}; 92int Four [8] [8] ={ 93 {0,0,0,0,1,2,0,0}, 94 {0,0,0,1,1,2,0,0}, 95 96 {0,0,1,2,1,2,0,0}, 97 {0,1,2,0,1,2,0,0}, 98 {0,1,1,1,1,1,2,0}, 99 {0,0,0,0,1,2,0,0}, 100 101 {0,0,0,0,1,2,0,0}, 102 {0,0,0,0,1,2,0,0}, 103}; 104int Five [8] [8] ={ 105 {0,1,1,1,1,1,2,0}, 106 107 {0,1,2,0,0,0,0,0}, 108 {0,1,2,0,0,0,0,0}, 109 {0,0,1,1,1,2,0,0}, 110 {0,0,0,0,0,1,2,0}, 111 112 {0,0,0,0,0,1,2,0}, 113 {0,1,2,0,0,1,2,0}, 114 {0,0,1,1,1,2,0,0}, 115}; 116 117int 118 Six [8] [8] ={ 119 {0,0,1,1,1,2,0,0}, 120 {0,1,2,0,0,1,2,0}, 121 {0,1,2,0,0,0,0,0}, 122 123 {0,1,1,1,1,2,0,0}, 124 {0,1,2,0,0,1,2,0}, 125 {0,1,2,0,0,1,2,0}, 126 {0,1,2,0,0,1,2,0}, 127 128 {0,0,1,1,1,2,0,0}, 129}; 130 131int Seven [8] [8] ={ 132 {0,1,1,1,1,1,2,0}, 133 134 {0,0,0,0,0,1,2,0}, 135 {0,0,0,0,0,1,2,0}, 136 {0,0,0,0,1,2,0,0}, 137 {0,0,0,1,2,0,0,0}, 138 139 {0,0,1,2,0,0,0,0}, 140 {0,0,1,2,0,0,0,0}, 141 {0,0,1,2,0,0,0,0}, 142}; 143 144int 145 Eight [8] [8] ={ 146 {0,0,1,1,1,2,0,0}, 147 {0,1,2,0,0,1,2,0}, 148 {0,1,2,0,0,1,2,0}, 149 150 {0,0,1,1,1,2,0,0}, 151 {0,1,2,0,0,1,2,0}, 152 {0,1,2,0,0,1,2,0}, 153 {0,1,2,0,0,1,2,0}, 154 155 {0,0,1,1,1,2,0,0}, 156}; 157 158int Nine [8] [8] ={ 159 {0,0,1,1,1,2,0,0}, 160 161 {0,1,2,0,0,1,2,0}, 162 {0,1,2,0,0,1,2,0}, 163 {0,0,1,1,1,1,2,0}, 164 {0,0,0,0,0,1,2,0}, 165 166 {0,0,0,0,0,1,2,0}, 167 {0,1,2,0,0,1,2,0}, 168 {0,0,1,1,1,2,0,0}, 169}; 170int 171 Zero [8] [8] ={ 172 {0,0,1,1,1,2,0,0}, 173 {0,1,2,0,0,1,2,0}, 174 {0,1,2,0,0,1,2,0}, 175 176 {0,1,2,0,0,1,2,0}, 177 {0,1,2,0,0,1,2,0}, 178 {0,1,2,0,0,1,2,0}, 179 {0,1,2,0,0,1,2,0}, 180 181 {0,0,1,1,1,2,0,0}, 182}; 183 184void setup() { 185 Serial.begin(9600); 186 Serial.println("resetting"); 187 188 // Declaring the matrix and setting the LED brightness 189 LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS); 190 LEDS.setBrightness(84); 191 192} 193// 194 Function to check which type of pixel (0,1 or 2) we have in coordinates i,j in the 195 array corresponding to digit passed by argument Number 196int Check_Pixel_In_Digit(int 197 Number, int i,int j){ 198int result; 199 if (Number ==0) result=Zero[i][j]; 200 201 if (Number ==1) result=One[i][j]; 202 if (Number ==2) result=Two[i][j]; 203 if (Number 204 ==3) result=Three[i][j]; 205 if (Number ==4) result=Four[i][j]; 206 if (Number ==5) 207 result=Five[i][j]; 208 if (Number ==6) result=Six[i][j]; 209 if (Number ==7) result=Seven[i][j]; 210 211 if (Number ==8) result=Eight[i][j]; 212 if (Number ==9) result=Nine[i][j]; 213 return 214 result; 215 216} 217 218 219void loop() { 220 //Repeat 100 times action of randomly 221 selecting a pixel and assigning a random color to it to wipe out the currently displayed 222 digit 223 for (int y=0;y<100;y++){ 224 led_x=random(0,8); 225 led_y=random(0,8); 226 227 Random_Color=random(0,27); 228 leds[(led_y)*8+led_x]=Colors[Random_Color]; 229 230 FastLED.show(); 231 delay(5); 232 } 233 //Repeat 200 times action of 234 randomly selecting a pixel and setting it to a pixel from the digit array corresponding 235 with Current_digit 236 for (int y=0;y<250;y++){ 237 led_x=random(0,8); 238 239 led_y=random(0,8); 240 if (Check_Pixel_In_Digit(Current_Digit,led_x,led_y)==1) 241 leds[(led_x)*8+led_y]=CHSV( 0 , 0, 255); 242 if (Check_Pixel_In_Digit(Current_Digit,led_x,led_y)==2) 243 leds[(led_x)*8+led_y]=Colors[Current_Color]; 244 if (Check_Pixel_In_Digit(Current_Digit,led_x,led_y)==0) 245 leds[(led_x)*8+led_y]=CHSV( 0 , 0, 0); 246 FastLED.show(); 247 delay(2); 248 249 } 250 // Redisplay the number again in full in case we did not address all 251 the pixels in the previous step 252 for (int i=0;i<8;i++){ 253 for (int j=0;j<8;j++){ 254 255 if (Check_Pixel_In_Digit(Current_Digit,i,j)==1) leds[(i)*8+j]=CHSV( 0 , 0, 255); 256 257 if (Check_Pixel_In_Digit(Current_Digit,i,j)==2) leds[(i)*8+j]=Colors[Current_Color]; 258 259 if (Check_Pixel_In_Digit(Current_Digit,i,j)==0) leds[(i)*8+j]=CHSV( 0 , 0, 0); 260 261 } 262 } 263FastLED.show(); 264delay(1000); 265 266// Descrease current 267 digit by one 268Current_Digit=Current_Digit-1; 269 270// Generate the outline color 271 for the next digit and making sure it is going to be a different one each time 272 273while 274 (Random_Color==Current_Color){ 275 Random_Color=random(0,27); 276} 277Current_Color=Random_Color; 278 279// 280 if zero is reached we start the countdown again from 9 281if (Current_Digit==-1){ 282 283 Current_Digit=9; 284} 285 286}
Color Blur Transition
arduino
Randomly select pixels and set them to random colors. Then randomly select pixels and send them to color corresponding with tarhet digit
1// MARIO's IDEAS 2// "Final Countdown" on WS2812 Matrix 3// Color Blur transition 4// After displaying the digit randomly select pixels and lit them with random colors 5// Then we randomly select pixels and set them to the colors that correspond with next digit to display 6 7#include <FastLED.h> 8 9// Variables to store the current digit we . We start with 9 10int Current_Digit=9; 11int led_x; 12int led_y; 13 14//A selection of colors we randommly choose from to define the color of the outline of the digit 15uint16_t Colors [27]{0x7FFF00,0x6495ED,0xDC143,0x00008B,0x8B008B,0xFF8C00,0x00CED1,0x9400D3, 16 0xFF1493,0x228B22,0xFFD700,0xADFF2F,0x7CFC00,0x87CEFA,0x00FF00,0xFF00FF, 17 0x0000CD,0xFFA500,0x9ACD32,0xFFE4C4,0x00FFFF,0x008B8B,0xE9967A,0xFFFACD,0xADD8E6,0xFAFAD2,0xFFEFD5}; 18 19// Variables used to store the colors. They store the index of the color in the Colors array 20int Current_Color=1;// color of the outline of the current digit 21int Random_Color=2;//used for random color generation 22 23 24// How many leds in your strip? 25#define NUM_LEDS 64 26 27// For led chips like Neopixels, which have a data line, ground, and power, you just 28// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, 29// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN 30#define DATA_PIN 5 31 32// Define the array of leds 33CRGB leds[NUM_LEDS]; 34 35// 8x8 Arrays ZERO to NINE defining the layout of pixels in each digit. 0- blank pixel, 1 - the digit pixel, 2 - the outline pixel 36 37int One [8] [8] ={ 38 {0,0,0,0,1,2,0,0}, 39 {0,0,0,1,1,2,0,0}, 40 {0,0,1,2,1,2,0,0}, 41 {0,1,2,0,1,2,0,0}, 42 {0,0,0,0,1,2,0,0}, 43 {0,0,0,0,1,2,0,0}, 44 {0,0,0,0,1,2,0,0}, 45 {0,0,0,0,1,2,0,0}, 46}; 47int Two [8] [8] ={ 48 {0,0,1,1,1,2,0,0}, 49 {0,1,2,0,0,1,2,0}, 50 {0,0,0,0,0,1,2,0}, 51 {0,0,0,0,1,2,0,0}, 52 {0,0,0,1,2,0,0,0}, 53 {0,0,1,2,0,0,0,0}, 54 {0,1,2,0,0,0,0,0}, 55 {0,1,1,1,1,1,2,0}, 56}; 57int Three [8] [8] ={ 58 {0,0,1,1,1,2,0,0}, 59 {0,1,2,0,0,1,2,0}, 60 {0,0,0,0,0,1,2,0}, 61 {0,0,0,1,1,2,0,0}, 62 {0,0,0,0,0,1,2,0}, 63 {0,0,0,0,0,1,2,0}, 64 {0,1,2,0,0,1,2,0}, 65 {0,0,1,1,1,2,0,0}, 66}; 67int Four [8] [8] ={ 68 {0,0,0,0,1,2,0,0}, 69 {0,0,0,1,1,2,0,0}, 70 {0,0,1,2,1,2,0,0}, 71 {0,1,2,0,1,2,0,0}, 72 {0,1,1,1,1,1,2,0}, 73 {0,0,0,0,1,2,0,0}, 74 {0,0,0,0,1,2,0,0}, 75 {0,0,0,0,1,2,0,0}, 76}; 77int Five [8] [8] ={ 78 {0,1,1,1,1,1,2,0}, 79 {0,1,2,0,0,0,0,0}, 80 {0,1,2,0,0,0,0,0}, 81 {0,0,1,1,1,2,0,0}, 82 {0,0,0,0,0,1,2,0}, 83 {0,0,0,0,0,1,2,0}, 84 {0,1,2,0,0,1,2,0}, 85 {0,0,1,1,1,2,0,0}, 86}; 87 88int Six [8] [8] ={ 89 {0,0,1,1,1,2,0,0}, 90 {0,1,2,0,0,1,2,0}, 91 {0,1,2,0,0,0,0,0}, 92 {0,1,1,1,1,2,0,0}, 93 {0,1,2,0,0,1,2,0}, 94 {0,1,2,0,0,1,2,0}, 95 {0,1,2,0,0,1,2,0}, 96 {0,0,1,1,1,2,0,0}, 97}; 98 99int Seven [8] [8] ={ 100 {0,1,1,1,1,1,2,0}, 101 {0,0,0,0,0,1,2,0}, 102 {0,0,0,0,0,1,2,0}, 103 {0,0,0,0,1,2,0,0}, 104 {0,0,0,1,2,0,0,0}, 105 {0,0,1,2,0,0,0,0}, 106 {0,0,1,2,0,0,0,0}, 107 {0,0,1,2,0,0,0,0}, 108}; 109 110int Eight [8] [8] ={ 111 {0,0,1,1,1,2,0,0}, 112 {0,1,2,0,0,1,2,0}, 113 {0,1,2,0,0,1,2,0}, 114 {0,0,1,1,1,2,0,0}, 115 {0,1,2,0,0,1,2,0}, 116 {0,1,2,0,0,1,2,0}, 117 {0,1,2,0,0,1,2,0}, 118 {0,0,1,1,1,2,0,0}, 119}; 120 121int Nine [8] [8] ={ 122 {0,0,1,1,1,2,0,0}, 123 {0,1,2,0,0,1,2,0}, 124 {0,1,2,0,0,1,2,0}, 125 {0,0,1,1,1,1,2,0}, 126 {0,0,0,0,0,1,2,0}, 127 {0,0,0,0,0,1,2,0}, 128 {0,1,2,0,0,1,2,0}, 129 {0,0,1,1,1,2,0,0}, 130}; 131int Zero [8] [8] ={ 132 {0,0,1,1,1,2,0,0}, 133 {0,1,2,0,0,1,2,0}, 134 {0,1,2,0,0,1,2,0}, 135 {0,1,2,0,0,1,2,0}, 136 {0,1,2,0,0,1,2,0}, 137 {0,1,2,0,0,1,2,0}, 138 {0,1,2,0,0,1,2,0}, 139 {0,0,1,1,1,2,0,0}, 140}; 141 142void setup() { 143 Serial.begin(9600); 144 Serial.println("resetting"); 145 // Declaring the matrix and setting the LED brightness 146 LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS); 147 LEDS.setBrightness(84); 148 149} 150// Function to check which type of pixel (0,1 or 2) we have in coordinates i,j in the array corresponding to digit passed by argument Number 151int Check_Pixel_In_Digit(int Number, int i,int j){ 152int result; 153 if (Number ==0) result=Zero[i][j]; 154 if (Number ==1) result=One[i][j]; 155 if (Number ==2) result=Two[i][j]; 156 if (Number ==3) result=Three[i][j]; 157 if (Number ==4) result=Four[i][j]; 158 if (Number ==5) result=Five[i][j]; 159 if (Number ==6) result=Six[i][j]; 160 if (Number ==7) result=Seven[i][j]; 161 if (Number ==8) result=Eight[i][j]; 162 if (Number ==9) result=Nine[i][j]; 163 return result; 164 165} 166 167 168void loop() { 169 //Repeat 100 times action of randomly selecting a pixel and assigning a random color to it to wipe out the currently displayed digit 170 for (int y=0;y<100;y++){ 171 led_x=random(0,8); 172 led_y=random(0,8); 173 Random_Color=random(0,27); 174 leds[(led_y)*8+led_x]=Colors[Random_Color]; 175 FastLED.show(); 176 delay(5); 177 } 178 //Repeat 200 times action of randomly selecting a pixel and setting it to a pixel from the digit array corresponding with Current_digit 179 for (int y=0;y<250;y++){ 180 led_x=random(0,8); 181 led_y=random(0,8); 182 if (Check_Pixel_In_Digit(Current_Digit,led_x,led_y)==1) leds[(led_x)*8+led_y]=CHSV( 0 , 0, 255); 183 if (Check_Pixel_In_Digit(Current_Digit,led_x,led_y)==2) leds[(led_x)*8+led_y]=Colors[Current_Color]; 184 if (Check_Pixel_In_Digit(Current_Digit,led_x,led_y)==0) leds[(led_x)*8+led_y]=CHSV( 0 , 0, 0); 185 FastLED.show(); 186 delay(2); 187 } 188 // Redisplay the number again in full in case we did not address all the pixels in the previous step 189 for (int i=0;i<8;i++){ 190 for (int j=0;j<8;j++){ 191 if (Check_Pixel_In_Digit(Current_Digit,i,j)==1) leds[(i)*8+j]=CHSV( 0 , 0, 255); 192 if (Check_Pixel_In_Digit(Current_Digit,i,j)==2) leds[(i)*8+j]=Colors[Current_Color]; 193 if (Check_Pixel_In_Digit(Current_Digit,i,j)==0) leds[(i)*8+j]=CHSV( 0 , 0, 0); 194 } 195 } 196FastLED.show(); 197delay(1000); 198 199// Descrease current digit by one 200Current_Digit=Current_Digit-1; 201 202// Generate the outline color for the next digit and making sure it is going to be a different one each time 203 204while (Random_Color==Current_Color){ 205 Random_Color=random(0,27); 206} 207Current_Color=Random_Color; 208 209// if zero is reached we start the countdown again from 9 210if (Current_Digit==-1){ 211 Current_Digit=9; 212} 213 214}
Documentation
Difussion panel
Difussion panel
Comments
Only logged in users can leave comments
mdraber
0 Followers
•0 Projects
Table of contents
Intro
3
0