Using Thonny to edit your code
Thonny is a programme that allows us to edit the code on various different microcontrollers. SPOKE is a type of microcontroller that specifically uses Circuitpython code to function.
The first step is to download and install Thonny from here: https://thonny.org/
When you first plug in your board, you will likely get a pop-up window that looks like this:
a screenshot of the contents of the usb-storage part of the SPOKE hardware
The file that stores all of the code and instructions for the board is the code.py file.
It is important that you don’t change the name of this file, the board will automatically run code.py when it powers up.
Open the code.py file in thonny
Thonny should look something like this:
The default code open in the Thonny editor
If your code doesn’t look like this, or is empty, you can just go to this link and copy/paste the default code from there.
To make sure we’re using the right settings, and talking to the right board, head to Run -> Select interpreter…
And from that menu you need to select Circuitpython (generic) for the interpreter, and then select the USB Serial Device (COMx) for the Port. In my example it is COM7, but yours could be different.
From here you are ready to edit your code or use the Shell to troubleshoot. For example, if you added a line of code onto line 47 that says “print (i)” it will display in the shell what midi note you’re sending over USB and even plot your note in a graph!
If you can’t see the Shell or Graph, then you’ll just need to toggle their visibility in the View tab.
NOTE - Whenever you change the code, you will need to hit the green ‘run code’ button to see any changes on your board.
Another fun example code to test out allows you to alter the threshold of when a pin is touched before it sends a midi message. This can be handy if you ever comes across problems with your setup being too sensitive, or not sensitive enough.
Copy this code from this link here. Replace the code in code.py with the new code, and now, when you delete the # on line 54 and hit run, it will give you raw sensor values whenever touch a pin. The number will be higher the more skin contact it has.