Run your first program

Step 2
Step completed?

Before we get into the code, let's first learn how to launch our first program on the Gamebuino!

Connect your Gamebuino

  1. Connect the Gamebuino to your computer using the USB cable

  1. Turn on your Gamebuino

  1. Start the CircuitPython program from the home screen. To launch it, select the icon with a snake image using the arrows on your Gamebuino (see image below: you can't miss it!), then press the A button. Press the A button a second time when the snake is displayed in full screen. Once CircuitPython is launched on your Gamebuino, it is possible that a window will open on your computer. We don't worry about it, you can even close it if you want!

  1. If everything went well, you should see the screen below appear on your Gamebuino. Perfect! Perfect! This means that your Gamebuino is ready to receive Python code. You can now click on "start" on your Gamebuino. If this is not the case, turn off your Gamebuino, and repeat the above steps in order.

Run your first program

  1. Launch the Mu software. This is a text editor in which you will write your programs. If you are in the workshop with us, it is possible that we have already launched it for you. Simply click on its icon in the taskbar to open it!

  2. An empty window appears (see image below): this is where you will write your first program! If the window does not appear, or if an error message is displayed, close everything, and start over from the beginning: you may have skipped a step! 3.Click on "Mode'' on the left corner of the Mu window. Then, select : Adafruit Circuit Python. And press OK.

  3. Copy the code below, and paste it into the Mu window. Don't try to understand what this means, don't worry we'll see it together later!

from gamebuino_meta import begin, waitForUpdate, display, buttons, color

while True:
    waitForUpdate()
    display.clear()

    display.print("Hello world")
  1. Click on the Save button at the top of the window.
  2. In the window that opens, look for the folder "CIRCUITPY", and save the file under the name "code.py". Be careful, the location and name are important, don't be mistaken!

  1. Look at your Gamebuino: the screen has recharged and your program is running!

Note (Important !)

You may have noticed in the little piece of code above, the lines can be more or less shifted to the right. This is called indentation and it's essential in the Python language that it be strictly respected. Otherwise the code will not work !

Many times, if there is a problem for your code to be executed, the mistake can come from there.

To shift a line, we must use the tab character (the key with two arrows). A line of code "belongs" to the instructions bloc defined by the first line above it with one step less of indentation.

This is an ugly sentence, but do not worry, you have plenty of time to understand all of this ! You will quickly become familiar with it, it is actually very simple.

Well done!

You have just launched your very first program in Python, the result of which is to display the sentence "Hello, world" on the screen. It's a kind of tradition in the computer world: we create this first program to make sure that everything works as it should. So that's good news! If you see this sentence on the screen of your Gamebuino, it is because we can get down to business.

If nothing appears, try to start over from the beginning. In programming, it is normal to make mistakes, and not everything necessarily works the first time, even for the most experienced programmers!

Steps