Sphero Support logo
Sphero Support logo

All articles

Debugging littleBits CodeUpdated 10 months ago

Having trouble with your Code? Here are some things to check: 

  • Is all your code connected to the start block? Code that isn’t connected to the [START] block and is just hanging out on the canvas will not run when you press upload, so be sure that your code blocks (other than function definitions) are attached to the [START] block

  • Are there any empty code blocks in your code? Empty blocks will keep your code from loading or running!

  • Do the inputs and outputs in your code match your circuit? Make sure that the inputs in your code match your circuit. For example, If you have one input in your circuit and its on IN 3, a [WAIT FOR IN1 TO BE ON] block is not going to work. You’ll want to change the input to IN 3 so it reads [WAIT FOR IN3 TO BE ON].

  • Do you have a [WAIT] block between frames of an animation? Code runs at a very fast speed, so if you don’t give it time to wait, it will move faster than your eyes can see! Make sure that animations have wait blocks between the images.    

  • Do you have a [WAIT] block after [SCROLLING TEXT] blocks? The code will not stop and wait for text to scroll on the LED matrix screen, so you will need to add a [WAIT] block after a [SCROLLING TEXT] block. The amount of wait time you give the scrolling text will correspond to the length of your scrolling message. In the example below, we’ve added 5 seconds so we can see all of the “Hi There” message.

  • Are your [ROTATE] [MOVE] or [ADD] blocks followed by a [SEND IMAGE] block? Blocks like [ROTATE IMAGE BY 90], [MOVE IMAGE UP BY 1] and [ADD PIXEL AT X: Y: TO IMAGE] need a [SEND IMAGE] block after them for them to be shown on the LED matrix.

        

  • Are your dark blue logic blocks inside of a dark gray loop block? If you want to check a logic block the whole time your program is running, make sure it is inside of a [DO FOREVER] loop. For example, if you have a button on IN 1 and you have a dark blue logic block to tell you when it’s been pressed, you’ll need to put it inside of a [DO FOREVER] block. This way, you’re constantly checking over and over again whether it’s being pressed. If you don’t put it inside of a loop block, it will only check to see whether it’s been pressed one time, and will then move onto the next code in the program.

  • Are you both SETTING and USING the variables you’ve created? This may seem like a silly one, but make sure that you both set your variable to a value AND use the variable in your code.

 

If you’re still having trouble, our Customer Success is happy to help! You can contact us here or at [email protected].

Was this article helpful?
Yes
No