Led matrix convert string

Hello,

I want to display a smiley on a led matrix:
This works fine:

matrix.clear();
static const uint8_t PROGMEM
smile_bmp[] =   { B00111100,B01000010,B10100101,B10000001,B10100101,B10011001,B01000010,B00111100 };
matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
matrix.writeDisplay();

But now I get the smiley code as a string.
That isn't work with my code:

String matrix_daten = "B00000000,B01000010,B10100101,B10000001,B10100101,B10011001,B01000010,B00111100"; 
matrix.clear();
static const uint8_t PROGMEM
smile_bmp[] =   matrix_daten;
matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
 matrix.writeDisplay();

How can I convert my code correctly.
Thank you for help.

regards
Christoph

But now I get the smiley code as a string

Where and how are you getting this data ?

Hi,
thank you for answer.

Here is my complete code. The string comes over the www:

#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"

Adafruit_8x8matrix matrix = Adafruit_8x8matrix();

      
    byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xFE, 0x92 };
    byte ip[] = { 192,168,2,108 };
    byte gateway[] = { 192,168,1, 1 };
    byte subnet[] = { 255, 255, 0, 0 };
    EthernetServer server(80); //server port
    String readString;

    //////////////////////
     
    void setup(){
     
      //start Ethernet
      Ethernet.begin(mac, ip, gateway, subnet);
      server.begin();
      Serial.begin(9600);
      Serial.println("Arduino ist waitung for matrix data"); 
  
  matrix.begin(0x70);  // pass in the address
  matrix.setBrightness(15); // 0 to 15
  matrix.blinkRate(0);
    }
     
    void loop(){
      // Create a client connection
      EthernetClient client = server.available();
      if (client) {
        while (client.connected()) {
          if (client.available()) {
            char c = client.read();
     
            //read char by char HTTP request
            if (readString.length() < 100) {
     
              //store characters to string
              readString += c;
              //Serial.print(c);
            }
     
            //if HTTP request has ended
            if (c == '\n') {
     
              ///////////////
              Serial.println(readString); //print to serial monitor for debuging
     
              client.println("HTTP/1.1 200 OK"); //send new page
              client.println("Content-Type: text/html");
              client.println();

     
              delay(1);
              //stopping client
              client.stop();

        
              //String matrix_daten = splitString(readString,'@',1);
               //Serial.println("-->"+matrix_daten);
               //String matrix_daten = "B00000000,B01000010,B10100101,B10000001,B10100101,B10011001,B01000010,B00111100"; 
                matrix.clear();
                static const uint8_t PROGMEM
                smile_bmp[] =   { B00111100,B01000010,B10100101,B10000001,B10100101,B10011001,B01000010,B00111100 };
                matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
                matrix.writeDisplay();
               
               
               
              //clearing string for next read
              readString="";
     
            }
          }
        }
      }
    }



String splitString(String s, char parser,int index){
  String rs='\0';
  int parserIndex = index;
  int parserCnt=0;
  int rFromIndex=0, rToIndex=-1;

  while(index>=parserCnt){
    rFromIndex = rToIndex+1;
    rToIndex = s.indexOf(parser,rFromIndex);

    if(index == parserCnt){
      if(rToIndex == 0 || rToIndex == -1){
        return '\0';
      }
      return s.substring(rFromIndex,rToIndex);
    }
    else{
      parserCnt++;
    }

  }
  return rs;
}

This is the url to send teh string:
http://192.168.2.108/?@B00000000,B01000010,B10100101,B10000001,B10100101,B10011001,B01000010,B00111100@

The data in the array you first posted is NOT a string. Why you think that a string is a suitable substitute escapes me.

You could store the character data in a char array, NULL terminated., and then use strtok() to extract the tokens between commas, and use bitSet() to set bits in a variable corresponding to the '1's in the token. Converting the string to something that the function can use is not hard, but it requires that YOU do some work. The conversion is NOT automatic.

Thank you for your tips.
But I am a beginner.
I tried the following:

               char matrix_daten[] = {"B00000000,B01000010,B10100101,B10000001,B10100101,B10011001,B01000010,B00111100"}; 
               char *d = strtok(matrix_daten,",");
             
              matrix.clear();
             for (int i=0; i<8; i++) {
             byte matrix_row = matrix_daten[i];
             Serial.println(matrix_row);
                
               
                static const uint8_t PROGMEM
                smile_bmp[] =   { matrix_row };
                matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
                matrix.writeDisplay();
               }

But I do not really understand the conversion.
Please can you help again?

But I do not really understand the conversion.

What conversion? You got a pointer to the first token. What does that pointer point to? Where do you attempt to do anything with what the pointer points to?

Use Tools + Auto Format to fix up your crappy indenting before you post code again.

You need a while loop that iterates over the string, extracting all the tokens, one at a time.

char *token = strtok(matrix_daten, ",");
while(token)
{
   useToken(token);

   token = strtok(NULL, ",");
}

In the useToken() function, print the token so you KNOW what you are dealing with. Then, use a for loop to iterate over the characters:

void useToken(char *token)
{
   byte val = 0; // Sets val to B00000000

   for(byte b=1; b<=8;b++)
   {
       if(token[b] == '1')
          bitSet(val, b-1); // set the bit (use i-1 because we skipped the B at the start of the token
   }

   // Store val in smile_bmp, at the appropriate place
   // Increment index so next time the appropriate place is known
}

Many thanks for the patience.
I think it is too difficult for me to realize my project.
I give up.

Regards
Christoph

I think it is too difficult for me to realize my project.

That depends on how much you are willing to learn.

I give up.

I guess that answers that.