Debugging your Code Kit inventions is an important skill that takes some time to develop! When you’re debugging, it’s good to identify what it is you are expecting your circuit to do and then think about what is is actually doing. You can find a printable debugging checklist here.
DEBUGGING YOUR CONNECTION
First, you’ll want to make sure you are connected to your codeBit.
- Is your codeBit Dongle plugged in?
If not, plug it in!
Windows 7/8 Users:
If you disconnect either the codeBit dongle (or the USB cable if connected directly to the codeBit) while the Code Kit app is running, you will need to restart your computer to reconnect to your codeBit.
- Is your codeBit connected to the Code Kit app?
If your codeBit is connected to the app, the purple bar at the bottom of the code canvas should say that it is connected. If your codeBit is not connected to the app, press the CONNECT YOUR CODEBIT button in the purple bar at the bottom of your screen.
- Does your circuit need to be refreshed?
Try disconnecting and reconnecting the p3 power Bit from your circuit. Then, upload your code again. Does this fix the problem? If not, try saving your code and restarting the app.
- Does your circuit have power?
Your circuit always needs a power source and will need to be connected to a p3 power Bit in order for it to work!
DEBUGGING YOUR CIRCUIT
- Are your Bits clean?
Sometimes, gunk can build up on the colorful bitSnaps of your Bits, which will prevent the signal from traveling through the circuit.
- Is your LED matrix correct?
Be sure the LED matrix is on SERIAL mode and is snapped to IN 1 of the codeBit when you are sending images to it through the app.
- Is your speaker correct?
Make sure your speaker Bit’s volume is up and that it is snapped to OUT 2 or OUT 3 of the codeBit.
- Are powerSnaps snapped to every input that isn’t connected to a power Bit?
If not, add them!
DEBUGGING YOUR CODE
- Are there any empty code blocks in your code?
Empty blocks will keep your code from loading or running.
- Is all your code connected to the [START] block?
Code that isn’t connected to the [START] block (other than function definitions) will not run when you press upload.
- 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 a [WAIT FOR IN 3 TO BE ON] block in your code, your codeBit should have an input on IN 3.
- Is your code running on the Bit?
When code is running, the red LED on the codeBit will light up. If it’s not lit, upload your code again.
- Do you need 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 need 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 before you see the emoji face.
- 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.
- Do you need to put your logic blocks inside of a 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.