update time and scrolling text to ws2812 matrix display through bluetooth

I'm working on building an addressable LED strip based Display(37x8), which will display the Time and scroll some text.I am ready with the hardware and without Bluetooth it works well but if i add Bluetooth functions, it doesn't work.Please help me figure out the problem.

//Libraries
#include <Adafruit_GFX.h>
#include <dht.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include <SoftwareSerial.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

//Constants

#define PIN 6 // data pin for the display

SoftwareSerial btSerial(3, 4); // RX, TX
const int photoCell = A0;
dht DHT;
const int DHT22_PIN = 9; // Data pin of DHT 22
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const int wait = 20; // In milliseconds
const int spacer = 1;
const int width = 5 + spacer; // The font width is 5 pixels

//Variables
int chk, length, brLevel, photoCellValue, count = 0;
float hum, temp;
String msg;
boolean autoBR = true;
boolean messageCompleted = false;
boolean newMessage = false;
String tickerText = "LED Scrolling Display";
char incomingByte;
String command;
unsigned long previousMillis = 0; // will store last time LED was updated

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(37, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);

void setup() {
Serial.begin(9600);
btSerial.begin(9600);
setSyncProvider(RTC.get);
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(45);
matrix.setTextColor(matrix.Color(255, 0, 0));
matrix.fillScreen(HIGH);
}

void loop() {
unsigned long currentMillis = millis();
communication();
//Update thermometer and photoCell variables and on starting
if (count == 0) {
chk = DHT.read22(DHT22_PIN);
//Read data and store it to variables hum and temp
hum = DHT.humidity;
temp = DHT.temperature;
controlBR();
}
//Show content
if (currentMillis - previousMillis >= 1000) {
previousMillis = currentMillis;
count++; //Seconds
}
//First display the clock for 5sec
if (count >= 0 && count < 5) {
time();
}
//Then the day of the week for 3sec
else if (count >= 5 && count < 8) {
today();
}
//Then the date for 3sec
else if (count >= 8 && count < 11) {
date();
}
//Then the temperature for 3sec
else if (count >= 11 && count < 14) {
temperature();
}
//Then the humidity for 3sec
else if (count >= 14 && count < 17) {
humidity();
}
//Finally the ticker text
else if (count >= 17) {
scroll();
count = 0; //<----reset
}
}
//Bluetooth communication
void communication() {
if (btSerial.available() > 0) {
incomingByte = btSerial.read();
if (incomingByte == '>') {
messageCompleted = true;
newMessage = false;
}
else if (incomingByte == '<') {
newMessage = true;
}

if (newMessage) {
command.concat(incomingByte);
}
}

if (messageCompleted) {
//Brightness level
if (command.charAt(1) == 'B') {
if (command.substring(2) == "Auto") {
autoBR = true;
}
else {
autoBR = false;
brLevel = (command.substring(2)).toInt() - 1;

}
}
//Update clock
else if (command.charAt(1) == 'T') {
int h = (command.substring(2, 4)).toInt();
int m = (command.substring(5, 7)).toInt();
int s = (command.substring(8, 10)).toInt();
int D = (command.substring(11, 13)).toInt();
int M = (command.substring(14, 16)).toInt();
int Y = (command.substring(17, 21)).toInt();
setTime(h, m, s, D, M, Y);
}
//Update ticker text
else if (command.charAt(1) == 't') {
tickerText = command.substring(2);
Serial.println(tickerText);
}
command = "";
messageCompleted = false;
}
}
//Control brightness - It will run on every complete loop!
void controlBR() {
if (autoBR) {
photoCellValue = analogRead(photoCell);
photoCellValue = map(photoCellValue, 1023, 0, 0, 15);
matrix.setBrightness(photoCellValue); // Use a value between 0 and 15 for brightness
}
else {
matrix.setBrightness(brLevel); // Use a value between 0 and 15 for brightness
}
}
//Print time
void time() {
int HH = hour();
int MM = minute();
int SS = second();
Serial.println("string Time");
Serial.println(HH);
Serial.println(MM);
Serial.println(SS);
if (HH < 10) {
msg = "0" + String(HH) + ":";
}
else {
msg = String(HH) + ":";
}
if (MM < 10) {
msg += "0" + String(MM) + ":";
}
else {
msg += String(MM) + ":";
}
if (SS < 10) {
msg += "0" + String(SS);
}
else {
msg += String(SS);
}
length = msg.length() * width;

matrix.setCursor((37 - length) / 2, 0); // Center text
matrix.fillScreen(LOW);
matrix.print(msg);
matrix.show();
}
//Print day of week
void today() {
//Day of week
msg = daysOfTheWeek[weekday()];
length = msg.length() * width;
matrix.setCursor((37 - length) / 2, 0); // Center text
matrix.print(msg);
matrix.show();
}
//Print date
void date() {
//Date:
int dd = day();
int mm = month();
int yyyy = year();
if (dd < 10) {
msg = "0" + String(dd) + ":";
}
else {
msg = String(dd) + ":";
}
if (mm < 10) {
msg += "0" + String(mm) + ":";
}
else {
msg += String(mm) + ":";
}
msg += String(yyyy);
length = msg.length() * width;
matrix.setCursor((37 - length) / 2, 0); // Center text
matrix.fillScreen(LOW);
matrix.print(msg);
matrix.show();
}
//Print temp and humidity
void temperature() {
msg = "Temp: " + String(temp) + "oC";
length = msg.length() * width;
matrix.setCursor((37 - length) / 2, 0); // Center text
matrix.fillScreen(LOW);
matrix.print(msg);
matrix.show();
}
void humidity() {
msg = "Hum: " + String(hum) + "%";
length = msg.length() * width;
matrix.setCursor((37 - length) / 2, 0); // Center text
matrix.fillScreen(LOW);
matrix.print(msg);
matrix.show();
}

//Ticker Text
void scroll() {
for ( int i = 0 ; i < width * tickerText.length() + matrix.width() - 1 - spacer; i++ ) {

matrix.fillScreen(LOW);

int letter = i / width;
int x = (matrix.width() - 1) - i % width;
int y = (matrix.height() - 8) / 2; // center the text vertically

while ( x + width - spacer >= 0 && letter >= 0 ) {
if ( letter < tickerText.length() ) {
matrix.drawChar(x, y, tickerText[letter], HIGH, LOW, 1);
}

letter--;
x -= width;
}

matrix.show(); // Send bitmap to display

delay(wait);
}
}
//Control funcs. for display - Call them in void loop to test the LEDs
void fullOn() {
matrix.fillScreen(HIGH);
matrix.show();
}
void fullOff() {
matrix.fillScreen(LOW);
matrix.show();
}


bluetooth_checking_Scrolling_display.ino (6.44 KB)

create a sketch just to make sure your code for RTC to output to the Serial Monitor to make sure it works
create a sketch just to make sure you are able to send/receive from your Bluetooth module to make sure it works
integrate the 2 sketches into your LED sketch

That's how it should be done instead of one giant mess that you expect someone to clean up for you.

.

Thanks for your reply. All sketches works fine seperately. I found the problem ,the problem is it is getting the value one by for every loop what can i do to check it within a function

#include <SoftwareSerial.h>

SoftwareSerial btSerial(3, 4); // RX, TX

int chk, length, brLevel, photoCellValue, count = 0;
float hum, temp;
String msg;
boolean autoBR = true;
boolean messageCompleted = false;
boolean newMessage = false;
char incomingByte;
String command;
String tickerText;
void setup() {
Serial.begin(9600);
btSerial.begin(9600);
}

void loop() {
communication();
delay(500);
}
void communication() {
if (btSerial.available() > 0) {
incomingByte = btSerial.read();
if (incomingByte == '>') {
messageCompleted = true;
newMessage = false;
}
else if (incomingByte == '<') {
newMessage = true;
}

if (newMessage) {
command.concat(incomingByte);
}
}

if (messageCompleted) {
//Brightness level
if (command.charAt(1) == 'B') {
if (command.substring(2) == "Auto") {
Serial.println(command);
autoBR = true;
}
else {
autoBR = false;
brLevel = (command.substring(2)).toInt() - 1;
Serial.println(command);
}
}
//Update clock
else if (command.charAt(1) == 'T') {
int h = (command.substring(2, 4)).toInt();
int m = (command.substring(5, 7)).toInt();
int s = (command.substring(8, 10)).toInt();
int D = (command.substring(11, 13)).toInt();
int M = (command.substring(14, 16)).toInt();
int Y = (command.substring(17, 21)).toInt();
Serial.println(h);
Serial.println(m);
Serial.println(s);
Serial.println(D);
Serial.println(M);
Serial.println(Y);
}
//Update ticker text
else if (command.charAt(1) == 't') {
tickerText = command.substring(2);
Serial.println(tickerText);
}
command = "";
messageCompleted = false;
}
}