How To Make Bluetooth Control RGB Scrolling Text Display
Hello friends, this is Bluetooth control RGB LED scrolling display.
Connection Diagram :
Code:
RGB_LED_Matrix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
#include <SoftwareSerial.h> #include "Arduino.h" #include <Wire.h>//Include libraries: SoftwareSerial & Wire SoftwareSerial ESP_BT(0,1); //Define PIN11 & PIN12 as RX and TX pins #include <Adafruit_GFX.h> #include <Adafruit_NeoMatrix.h> #include <Adafruit_NeoPixel.h> #include <EEPROM.h> #ifndef PSTR #define PSTR // Make Arduino Due happy #endif #define PIN 5 // MATRIX DECLARATION: // Parameter 1 = width of NeoPixel matrix // Parameter 2 = height of matrix // Parameter 3 = pin number (most are valid) // Parameter 4 = matrix layout flags, add together as needed: // NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT: // Position of the FIRST LED in the matrix; pick two, e.g. // NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner. // NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal // rows or in vertical columns, respectively; pick one or the other. // NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed // in the same order, or alternate lines reverse direction; pick one. // See example below for these values in action. // Parameter 5 = pixel type flags, add together as needed: // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) // NEO_GRBW Pixels are wired for GRBW bitstream (RGB+W NeoPixel products) // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) // Example for NeoPixel Shield. In this application we'd like to use it // as a 5x8 tall matrix, with the USB port positioned at the top of the // Arduino. When held that way, the first pixel is at the top right, and // lines are arranged in columns, progressive order. The shield uses // 800 KHz (v2) pixels that expect GRB color data. Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix( 32, //Select LEDs of each row (15 in my case) 8, //Select amount of rows (7 in my case) PIN, NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT + //Define first data pin (right bottom corner is my first pin) NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG, //Define the type of connection (in a zig zag connections and divided by rows not columns) NEO_RGB + NEO_KHZ800); int Red=255,Green=0,Blue=0; String text="Easy Tech"; String RGB; int pixelPerChar = 5,RGB_Completed=0; int Delay, Brightness; const uint16_t colors[] = {matrix.Color(Green,Red,Blue)}; // matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };//matrix.Color(Red, Green, Blue), void setup() { Serial.begin(115200); ESP_BT.begin(9600); EEPROM.begin(); initdata(); // Serial.println("Start"); const uint16_t colors[] = {matrix.Color(Green,Red,Blue)}; matrix.begin(); matrix.setTextWrap(false); matrix.setBrightness(Brightness); matrix.setTextColor(colors[0]); //matrix.setTextColor(matrix.Color(Green,Red,Blue)); } int x = matrix.width(); int pass = 0; void loop() { while(ESP_BT.available()){ char ReadChar = (char)ESP_BT.read(); Serial.println(ReadChar); // Right parentheses ) indicates complet of the string if(ReadChar == ')' ||ReadChar == '}' || ReadChar == ']'){ if(ReadChar == ')' ){ RGB_Completed = 1; } if(ReadChar == '}'){ RGB_Completed = 2; } if(ReadChar == ']'){ RGB_Completed = 3; } } else{ RGB += ReadChar; } } if(RGB_Completed!=0){ if(RGB_Completed==1){ Light_RGB_LED(); RGB_Completed=0; } if (RGB_Completed==2){ text=RGB; int _size = text.length(); int i; for(i=0;i<_size;i++) { EEPROM.write(50+i,text.charAt(i)); Serial.println(text.charAt(i)); } EEPROM.write(50+_size,'\0'); //Add termination null character for String Data RGB_Completed=0; RGB=""; } if (RGB_Completed==3){ int val=RGB.toInt(); if(val>0 && val<=100){ if(val==0){ val=1; } Delay=(100-val)*2.5; //scroll(Delay); EEPROM.write(0,Delay); } else{ val=val-100; matrix.setBrightness(val); EEPROM.write(5,val); } RGB=""; RGB_Completed=0; } } if(RGB_Completed==0){ //. Serial.println(RGB_Completed); scroll(); } } void scroll(){ //Serial.println(text); int maxDisplacement = text.length() * pixelPerChar + matrix.width(); matrix.fillScreen(0); matrix.setCursor(x, 0); matrix.print(text); if(--x < -maxDisplacement) { x = matrix.width(); if(++pass >= 1){ pass = 0; // matrix.setTextColor(colors[pass]); matrix.setTextColor(matrix.Color(Green,Red,Blue)); // matrix.setTextColor(matrix.Color(Red,Green,Blue)); } } matrix.show(); delay(Delay); } void Light_RGB_LED(){ int SP1 = RGB.indexOf('.'); int SP2 = RGB.indexOf('.', SP1+1); int SP3 = RGB.indexOf('.', SP2+1); String R = RGB.substring(0, SP1); String G = RGB.substring(SP1+1, SP2); String B = RGB.substring(SP2+1, SP3); Red=R.toInt();Green=G.toInt();Blue=B.toInt(); // Serial.println(R); matrix.setTextColor(matrix.Color(Green,Red,Blue)); EEPROM.write(10,Red);EEPROM.write(15,Green);EEPROM.write(20,Blue); RGB=""; } |
Function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
void initdata(){ int Speed=EEPROM.read(0); if(Speed==NULL || Speed==0){ Delay=100; } else{ Delay=Speed; } int bright= EEPROM.read(5); if(bright==NULL || bright==0){ Brightness=40; } else{ Brightness=bright; } int r= EEPROM.read(10); if(r==NULL){ Red=0; } else{ Red=r; } int g= EEPROM.read(15); if(g==NULL){ Green=255; } else{ Green=g; } int b= EEPROM.read(20); if(b==NULL){ Blue=0; } else{ Blue=b; } char data[100]; //Max 100 Bytes int len=0; char k; String Text= ""; k=EEPROM.read(50); while(k != '\0' && len<500) //Read until null character { k=EEPROM.read(50+len); data[len]=k; Text+=k; len++; } data[len]='\0'; if(Text==NULL){ text="EASY TECH"; } else{ text=Text; } Serial.println(Speed); Serial.println(Brightness); Serial.println(Red); Serial.println(Green); Serial.println(Blue); Serial.println(text); } |
What app are you using to control your display? IOS/Android?
https://play.google.com/store/apps/details?id=com.easy.tech.leddisplay
nice artilce , thank you . keep it up
nice artilce , thank you . keep it up
Muy buenas noches, me presento mi nombre es Dumar,
Muchas gracias por el proyecto que ha realizado
Lo que sucede es que estamos realizando una matriz de 32 x 16 con el modulo Bluetooth, aplicando su codigo que implemento, queríamos pedir el favor de que si nos pudiera ayudar, ya que llegamos a un punto de no poder configurar.
Se los agradecemos de antemano.
\filepro.ino:4:16: warning: NULL used in arithmetic [-Wpointer-arith]
if(Speed==NULL || Speed==0){
^~~~
\filepro.ino:12:17: warning: NULL used in arithmetic [-Wpointer-arith]
if(bright==NULL || bright==0){
^~~~
\filepro.ino:20:12: warning: NULL used in arithmetic [-Wpointer-arith]
if(r==NULL){
^~~~
\filepro.ino:28:12: warning: NULL used in arithmetic [-Wpointer-arith]
if(g==NULL){
^~~~
\filepro.ino:36:12: warning: NULL used in arithmetic [-Wpointer-arith]
if(b==NULL){
^~~~
I am using Nano IOT 33. On uploading the code, I get errors related to SoftwareSerial.h, Wire.h, EEprom.h. I searched online and found errors are due to SAMD architecture of Nano instead of AVR. Can you explain which Nano did you use?