<SoftwareSerial.h> SoftwareSerial mySerial(9, 10); String textMessage;

#include <SoftwareSerial.h>

SoftwareSerial mySerial(9, 10);
String textMessage;

#include <Adafruit_GFX.h>
#include <FastLED.h>
#include <FastLED_NeoMatrix.h>

#define PIN 6

#define mw 6
#define mh 9
#define NUMMATRIX (mw*mh)

CRGB matrixleds[NUMMATRIX];

FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(matrixleds, mw, mh, mw/6, 1,
NEO_MATRIX_TOP + NEO_MATRIX_RIGHT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG );

const uint16_t colors[] = {
matrix->Color(255, 0, 0), matrix->Color(0, 255, 0), matrix->Color(0, 0, 255) };

void setup() {
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);

FastLED.addLeds<NEOPIXEL,PIN>(matrixleds, NUMMATRIX);
matrix->begin();
matrix->setTextWrap(false);
matrix->setBrightness(40);
matrix->setTextColor(colors[0]);

}

int x = mw;
int pass = 0;

void loop() {

if(mySerial.available()>0){
textMessage = mySerial.readString();
Serial.print(textMessage);
delay(10);
}

matrix->fillScreen(0);
matrix->setCursor(x, 1);
matrix->print(textMessage.indexOf(“”));
if(–x < -15) {
x = matrix->width();
if(++pass >= 3) pass = 0;
matrix->setTextColor(colors[pass]);
}
matrix->show();
delay(300);

}

help me again guys :slight_smile: I’m working with my project right now , that the message will display in RGB LED strip using a text message(SMS) . My problem is my project keep displaying between -1 and 0 .

matrix->print(textMessage.indexOf(“”)); this is the code
what is the right code to get the data or text in GSM Module . TIA guys :slight_smile: :slight_smile:

IndexOf returns an int. so that is why you have only 0 and -1
Try first with only print(textMessage) I guess some times you can have some rubbish at the end of the message.
I guess the the initial purpose was to ‘cut’ the string when it finds the first char(0).

@Yves_BAZIN I already try that code but nothing will display in RGB LED strip

@jester_salivio have you tried a fix string like print(‘test’).

@Yves_BAZIN yes and it’s working

@jester_salivio move the ‘}’ after the delay(10) to after delay(300).

@Yves_BAZIN nothing happen man

@jester_salivio can I see your latest code ? On gist it will be easier to read ? Do you see the serial.print(textmesssage) ?

FastLED’s bitbang-based WS2812 driver and SoftwareSerial usually do not work well together, due to disabling interrupts.

@Yves_BAZIN https://gist.github.com/jsteer011/3c414f8737af705b17de57c3338ab145

@Yves_BAZIN yes man , why ?

@PaulStoffregen what should i do ? :frowning:

@jester_salivio because that means the variable is correctly updated. your code works with a constant so it’s kinda strange I have to admit.
Could you try that :
line 50: textMessage = “test”;

I want to know the the function matrix->print uses string or a char[]

@jester_salivio try this
textMessage = mySerial.readString();
char buff[256];
textMessage.toCharArray(buff,256);
Serial.print(textMessage);


matrix->print(buff)

@Yves_BAZIN I used this code

if(mySerial.available()>0){
textMessage = mySerial.readString();
Serial.print(textMessage);

delay(10);

}

textMessage = “Test”;

matrix->fillScreen(0);
matrix->setCursor(1, 1);
matrix->print(textMessage);

matrix->setTextColor(colors[pass]);

matrix->show();
delay(300);

and it works

@Yves_BAZIN the next you suggested code didn’t display

@jester_salivio try this
void loop() {

textMessage="";
if(mySerial.available()>0){
textMessage = mySerial.readString();
Serial.print(textMessage);
delay(10);
}

if(textMessage.length()>0)
{
matrix->fillScreen(0);
matrix->setCursor(1, 1);
matrix->print(textMessage);

	matrix->setTextColor(colors[pass]);

  matrix->show();
  delay(300);

}

}

@Yves_BAZIN nothing happen man but thank you for helping me :slight_smile:

@jester_salivio I am sorry I don"t see why it doesn’t want to print a text within the variable. can you add this just before the matrix->print
Serial.printf(“string:%s:endstring\n”,textMessage);
can you tell me where you got the library from ? maybe i can have a look at the print function and see why we seemed to call it wrong

@Yves_BAZIN It’s okay man , I’m happy because someone is helping me