About showing text and numbers in LED matrix


#1

Hi all,
I got a LED matrix times ago. And I find that mbot supports showing either numbers or string or bitmap picture to the LED matrix but I wonder if there is any way to do the following with mBlock language

  1. I have some numeric variables, I want to show a string including the value of the certain numeric variable, e.g. “It costs $3” where 3 read from a variable.

  2. by using show face number or show face text, I can show whatever I input to the matrix but is there any way to rotate the text or number before showing to the matrix?

Thanks.


My code is not working
#2

Weird, I can make numbers change but the dollar sign never appears. Haven’t dug into the source code, so it might be getting stripped there, possibly because $ is a reserved symbol? Will do some further research.

@tec_support, shouldn’t the dollar sign ($) be displayed?


#3

Weird, I can make numbers change but the dollar
sign never appears. Haven’t dug into the source code, so it might be
getting stripped there, possibly because $ is a reserved symbol? Will do
some further research.

@tec_support, shouldn’t the dollar sign ($) be displayed?

Hi chuckmcknight, so you could concatenate a string and a variable number before sending it to led matrix? Could you please tell how do you do that? Thanks.


#4

I tried doing that using the join block, but it would only display the number. The odder part is that I can display an exclamation point (!). When I looked at the code generated for the blocks, it appeared that it was an attempt to concatenate a string ($) to a number and then cast the entire thing as a string. Another possibility is the the dollar sign simply hasn’t been implemented. I’ll look at the library source code a bit later to see what I can suss out.


#5

I tried doing that using the join block, but
it would only display the number. The odder part is that I can display
an exclamation point (!). When I looked at the code generated for the
blocks, it appeared that it was an attempt to concatenate a string ($)
to a number and then cast the entire thing as a string. Another
possibility is the the dollar sign simply hasn’t been implemented. I’ll
look at the library source code a bit later to see what I can suss out.

It is great. I don’t even know that the join command can combine two different type variable. But it works now. Also, in my case, I cannot show the $ properly.

I still don’t find a way to rotate the output string in the led matrix.


#6

This is a sample program that demonstrates changing a number on the LED display:

You’ll need to create a variable in the Data&Blocks palette and use the set [variable] to [value] and change [variable] by [value] blocks from that palette as well.

Hope this helps.


#7

Thanks for the code. Yes, it works to change the number in time. But I still don’t know how to rotate the displayed number. I think it may be done in very lower level or modify the source code to do so.


#8

By rotate, do you mean rotate the orientation of the number? I’m not sure that’s possible from within mBlock. String orientation seems to be fixed in the Scratch end of the show face block. As you note, you’ll have to do your own mapping of the LED patterns for each orientation of each character.


#9

Hi Charles,

Yes, the mBlock program cannot display the dollar sign. It can display numbers and letters.


#10

Does anyone know if there is a limit to the number of characters that can be scrolled on the LED matrix? If you use the example Makeblock shows (with the green flag command), LED program with green flag command.sb2 (75.0 KB)
it seems it is possible to stream long strings from the show face command. However, if you change the green flag command to an mBot Program command and upload it to mBot, there seems to be a limit to the number of characters that will scroll from a long string. I’m wondering if this is a firmware or hardware issue??LED program with mBot command.sb2 (74.9 KB)


#11

Going through mBlock (Scratch), I would suspect the major limit is the amount of SRAM avaiable. Each character takes 1 byte of SRAM and after the Makeblock library code is loaded, you only have about 1K of SRAM left to hold all of your variables.


#12

Chuck, thanks for your quick reply. That makes sense. I saw elsewhere in the forum a teacher had asked a similar question where you gave a concise reply. I think “we” were probably looking for a way for the mBot to “communicate” with younger students through the matrix. It appears that can be done as long as the mBot is connected via the serial port and running a program via the green flag. But not through the mBot program command. Guess I shouldn’t expect more than that for $90. Maybe some day MakeBlock will figure a way to put a “memory stick” in the port where the Bluetooth gets plugged in??

Thanks again for helping us understand this little fellow.

Tom


#13

Confirmation from Makeblock: When the program is uploaded to the MCU chip on mBot, the whole script fails to scroll due to the insufficient memory resource in the MCU chip. The script can scroll successfully when the program is run on mBlock software bucause it uses the memory resource from the computer. And because of this, in our official website, we also recemmend our users to run this program on the computer.


#14

So, is there a way to use the example program in mBot without the When (green flag) clicked command? It appears it one tries to put the remainder of the program into an mBot “on-board program” (uploaded to Arduino), the blocks are “unsupported”.


#15

This one worked, but I didn’t set it up to scroll resulting in chopped off letters.


#16

Thanks Chuck. I think I’ve discovered that it is the Forever block that is not supported.


#17

Well, actually it is. :slight_smile:

The Forever block corresponds to the Arduino loop() method. However, for reasons I don’t get I often have to reinsert blocks that should be legal when I change from using the green flag block to the mBot program block.


#18

This gets more interesting. I popped the Forever loop into your program and indeed, it did work. But, if I try to put it into my program, it comes up as an unsupported block regardless of how many times I try to insert it. The program works with a repeat loop, but not a Forever loop. Strange.Display Emergency using blocks (sub routine) does not work with Forever - unsupported.sb2 (75.0 KB)


#19

One error I spotted immediately is in the comparison operator. If you have declared a variable, you must drag that variable from the variable palette and not type in the name.

However, I’m getting an error complaining about compiling for an Arduino/Genuino board which is new.

Update: Changing the board to Arduino Uno and then back to mCore seems to have eliminated the compilation error. However, it never scrolled so I’m not sure what’s up there.

@tec_support: The underlying Arduino environment seemed to be set for the Mega2560/MegaPi and wasn’t getting reset properly. This is in mBlock 3.4.1 for MacOS.


#20

Hi Charles,

We will test this issue and let you know later. Is this reproducible on your side?