Help with leading zeros, RGB

I have a canvas with a ball for RGB color picking. I'm trying to send the data to my arduino to parse and do stuff. I feel like the easiest way to do that is to always send a 9 digit number and parse it on my arduino code. So I'm trying to use leading zeros to always have 9 digits (000000000-255255255). This code seems to work over in the R area but not the other sections. Below is my serial monitor example.

is there another way to send and parse the RGB data that's easier, or can someone see what I did wrong with the leading zeros function?

Try with the list separator block


use an empty separator

You may still need the leading zeros ?

1 Like

Maybe I tried putting that in the wrong places, but with and without the leading zeros code it still doesn't produce the correct output. I've been working through this problem for two days and feel like there should be an apparent solution to the problem. But I'm not seeing one.

Like so ?

1 Like

where would I put that initialize local color block at? in the join values for the BLE write strings block or?

How is your serial monitor supposed to know where one string of digits ends and the next begins?

Yes, put it there.

where did the item variable come from in the call leadingzeros block you posted?

wouldn't the serial port not matter in this case? The problem seems to be with what is sent, not what is received. I have the arduino just printing whatever is received.

okay there's something wrong with the orange block. The only value that ever returns is the rgb for the yellowish color you put in "split color". No matter what the input is, the value printed is 255200000.

1 Like

You will need to replace the colour block (yellowish color) with your canvas pixel background color x,y value blocks, so that when the canvas is touched that value is fed to the procedure.

do I replace it with the whole "split color > getbackgroundpixelcolor x y" Or can I just pop in the global variables R, G, and B since they're already set to the result of the "getpixelcolor x y"

Ii should just be a case of replacing:


with this:

like this? seems like this block would just send the same variable 3 times.

You only need the orange block once, you do not need the join and the other two orange blocks