Components and supplies
Arduino Nano R3
Jumper wires (generic)
LED Dot Matrix Display, Red
Project description
Code
GoldScrew_LED_Matrix.ino
arduino
1 2/* 3 * LED Matrix MAX7219 4 * Author: GoldScrew 5 * Website: https://goldscrew.blogspot.com/ 6 * Youtube: https://www.youtube.com/c/GoldScrew 7 */ 8#include <MD_Parola.h> 9#include <MD_MAX72xx.h> 10#include <SPI.h> 11 12#define HARDWARE_TYPE MD_MAX72XX::FC16_HW 13 14// Defining size, and output pins 15#define MAX_DEVICES 4 16#define CS_PIN 10 17 18// Create a new instance of the MD_Parola class with hardware SPI connection 19MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES); 20 21// Messages in strings 22uint8_t curString = 0; 23const char *msg[] = 24{ 25 "*** GOLDSCREW ***", 26 "Welcome to GoldScrew channel", 27 "Like & Share", 28 "SUBSCRIBE", 29 "Hope you enjoy ^_^", 30 "LIKE", 31 "SHARE" 32}; 33 34// Pause time 35const uint16_t PAUSE_TIME = 1000; // in milliseconds 36 37// Sprite Definitions 38const uint8_t F_PMAN1 = 6; 39const uint8_t W_PMAN1 = 8; 40const uint8_t PROGMEM pacman1[F_PMAN1 * W_PMAN1] = // gobbling pacman animation 41{ 42 0x00, 0x81, 0xc3, 0xe7, 0xff, 0x7e, 0x7e, 0x3c, 43 0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c, 44 0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c, 45 0x3c, 0x7e, 0xff, 0xff, 0xff, 0xff, 0x7e, 0x3c, 46 0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c, 47 0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c, 48}; 49 50const uint8_t F_PMAN2 = 6; 51const uint8_t W_PMAN2 = 18; 52const uint8_t PROGMEM pacman2[F_PMAN2 * W_PMAN2] = // ghost pursued by a pacman 53{ 54 0x00, 0x81, 0xc3, 0xe7, 0xff, 0x7e, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe, 55 0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe, 56 0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe, 57 0x3c, 0x7e, 0xff, 0xff, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe, 58 0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe, 59 0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe, 60}; 61 62const uint8_t F_ROCKET = 2; 63const uint8_t W_ROCKET = 11; 64const uint8_t PROGMEM rocket[F_ROCKET * W_ROCKET] = // rocket 65{ 66 0x18, 0x24, 0x42, 0x81, 0x99, 0x18, 0x99, 0x18, 0xa5, 0x5a, 0x81, 67 0x18, 0x24, 0x42, 0x81, 0x18, 0x99, 0x18, 0x99, 0x24, 0x42, 0x99, 68}; 69 70const uint8_t F_WALKER = 5; 71const uint8_t W_WALKER = 7; 72const uint8_t PROGMEM walker[F_WALKER * W_WALKER] = // walking man 73{ 74 0x00, 0x48, 0x77, 0x1f, 0x1c, 0x94, 0x68, 75 0x00, 0x90, 0xee, 0x3e, 0x38, 0x28, 0xd0, 76 0x00, 0x00, 0xae, 0xfe, 0x38, 0x28, 0x40, 77 0x00, 0x00, 0x2e, 0xbe, 0xf8, 0x00, 0x00, 78 0x00, 0x10, 0x6e, 0x3e, 0xb8, 0xe8, 0x00, 79}; 80 81const uint8_t F_HEART = 5; 82const uint8_t W_HEART = 9; 83const uint8_t PROGMEM heart[F_HEART * W_HEART] = // beating heart 84{ 85 0x0e, 0x11, 0x21, 0x42, 0x84, 0x42, 0x21, 0x11, 0x0e, 86 0x0e, 0x1f, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x1f, 0x0e, 87 0x0e, 0x1f, 0x3f, 0x7e, 0xfc, 0x7e, 0x3f, 0x1f, 0x0e, 88 0x0e, 0x1f, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x1f, 0x0e, 89 0x0e, 0x11, 0x21, 0x42, 0x84, 0x42, 0x21, 0x11, 0x0e, 90}; 91 92void setup() { 93 Serial.begin(9600); 94 95 // Intialize the object 96 myDisplay.begin(); 97 98 // Set the intensity (brightness) of the display (0-15) 99 myDisplay.setIntensity(5); 100 101 // Show scroll Text 102 myDisplay.displayScroll(msg[curString], PA_LEFT, PA_SCROLL_LEFT, 100); 103} 104 105void loop() { 106 107 // Random 108 int ranIdx = random(6); 109 110// Serial.println(String(ranIdx)); 111 112 static uint8_t curFX = 0; 113 114 if (myDisplay.displayAnimate()) { 115 116 switch(ranIdx) 117 { 118 case 0: 119 myDisplay.displayText(msg[6], PA_CENTER, 100, PAUSE_TIME, PA_SPRITE, PA_SPRITE); 120 myDisplay.setSpriteData(rocket, W_ROCKET, F_ROCKET, rocket, W_ROCKET, F_ROCKET); 121 curString++; 122 break; 123 case 1: 124 myDisplay.displayScroll(msg[ranIdx], PA_LEFT, PA_SCROLL_LEFT, 100); 125 delay(2000); 126 break; 127 case 2: 128 myDisplay.displayScroll(msg[ranIdx], PA_RIGHT, PA_SCROLL_RIGHT, 100); 129 delay(2000); 130 break; 131 case 3: 132 myDisplay.displayText(msg[5], PA_CENTER, 100, PAUSE_TIME, PA_SPRITE, PA_SPRITE); 133 myDisplay.setSpriteData(walker, W_WALKER, F_WALKER, walker, W_WALKER, F_WALKER); 134 curString++; 135 break; 136 case 4: 137 myDisplay.displayScroll(msg[ranIdx], PA_LEFT, PA_SCROLL_LEFT, 100); 138 delay(2000); 139 break; 140 case 5: 141 myDisplay.displayText(msg[ranIdx], PA_CENTER, 100, PAUSE_TIME, PA_SPRITE, PA_SPRITE); 142 myDisplay.setSpriteData(pacman1, W_PMAN1, F_PMAN1, pacman2, W_PMAN2, F_PMAN2); 143 curString++; 144 break; 145 case 6: 146 myDisplay.displayScroll(msg[ranIdx], PA_CENTER, PA_SCROLL_UP, 100); 147 delay(2000); 148 break; 149 default: 150 myDisplay.displayText(msg[6], PA_CENTER, 100, PAUSE_TIME, PA_SPRITE, PA_SPRITE); 151 myDisplay.setSpriteData(heart, W_HEART, F_HEART, rocket, W_HEART, F_HEART); 152 curString++; 153 break; 154 } 155 156 // Reset display 157 myDisplay.displayReset(); 158 } 159} 160
Downloadable files
Circuit diagram
Circuit diagram
Circuit diagram
Circuit diagram
Comments
Only logged in users can leave comments
goldscrew
0 Followers
•0 Projects
0