Ball detection
Let’s code Wheelson to detect a ball and write out its location and radius on the screen.
The first steps are always the same - click on “New Sketch”, choose “Wheelson” as your device and “Block” as the Sketch type. After clicking “Create” the drawing board will open.
Since this program will write out some text on the screen let’s set the font size, type, and color.
From the “Display” function grab the “set font size to”, “set font type”, and “set font colour to” blocks one at a time and place them right below the “Arduino run first:” text.


Let’s set the font size to “1”, font type to “2”, and let’s leave the font color “green”. Just like this:

From the “Vision” section on the left side of the screen, grab the “fetch camera frame” block and drop it below the “Arduino loop forever:” text.


The camera frame is now in Wheelson’s memory so we have to add a block that will draw this on the screen. So, let’s add the “draw camera frame” block from


Let’s give Wheelson an instruction to detect the ball.
From the “Vision” section drag the “detect ball” block and drop it right below the “draw camera frame” block.
You can choose the color of the ball you have with the drop-down menu on the right side of this block. Our ball is blue so we’ve selected the blue color.


The same thing as before, this ball detection is now in Wheelson’s memory so we have to add a block that will draw this out to the screen.
To do that, let’s take the “draw sprite to display” block from the “Display” section and add it below the “detect ball” block.

Now, let’s add the “when ball is detected” block from the “Vision” section on the left.


Here we’ll add blocks that will instruct Wheelson to draw an outline of the detected ball and write out its location and radius on the screen.
Take the “draw circle with colour” block from the “Display” section and drop it inside the “when ball is detected” block.

Let’s select that the ball is “outlined” and that the “screen colour” is blue.

Now let’s add a value to x. You’ll see that there are red blocks on the bottom of the ”when ball is detected” block.
Drag the “ball.center.x” block and drop it in place of the x value that was previously there.


Let’s add values to y and radius next. Drag the “ball.center.y” block and place it next to y, and “ball.radius” block next to radius.
Just like this:

Now let’s give Wheelson and instruction to write out the location and radius of the ball on the screen.
Drag and drop the “print x, y” block from the “Display” section.


We want to show the ball’s location inside brackets with a comma in the middle so that, for example, this is the way location will show up on the screen: (10, 20).
So, let’s instruct him to do just that.
Grab the “create text with” block from the “Text” section and drop it inside the “print x, y” block.


Open the “Text” section again and find an empty text block. It’s a white block with red quotation marks inside it.
Drop it inside the “create text with” block.
We’ll write the first bracket that will appear while writing out the ball’s location on the screen, so type “(“ inside this block.


Right next to this, drag and drop the “ball.center.x” block from the bottom of the “when ball is detected” block to write out the ball’s x coordinate.

Let’s add the comma that will appear between the two coordinates, the ball’s y coordinate, and a bracket on the right. TO add these press the “+” button on the right side of this block.

Then, drag and drop another empty text block from the “Text” section, write “,” inside it, drag the “ball.center.y” block next to it, and finally, add an empty text block and write “)” inside it.
This is how this should look like:

Let’s add values to x and y inside the “print” block now.
Open the “math” section and find a block with a “+” sign between two numbers.

Drag and drop it in place of the x value.
Then, drag and drop the red “ball.center.x” block and place it on the left side of the block, and drag and drop the “ball.radius” block on the left side of this block.

Open the “Math” section again and this time grab a block with “-” symbol in the middle.
Add the “ball.center.y” block to the left value, and “ball.radius” block to the right. Just like this:

Let’s add another “print x, y” block from the “Display” section. We’ll fill the value next to the word print with a “create text with” block from the “Text” section.


Let’s add an empty text block from the “Text” section to the “create text with” block and write “R:” inside it. This will appear before Wheelson writes out the ball’s radius.
We’ll also assign a value to the empty block right next to this. Drag and drop the “ball.radius” block.
Take a look at the image below to see how this looks like:

There are only a few things left to do.
Let’s assign values to x and y inside this “print block”. From the “Math” section drag and drop a block with a “+” sign in the middle. Then, add “ball.center.x” block to the left value of the block, and the “ball.radius” block to the right.

Right below this block, let’s give y a value. Take the same block with a “+” sign in the middle of it from the “Math” section and drop it in place of the y value. Then, add the “ball.center.y” block on the left side, and “ball.radius” block to the left.
Just like this:
Just like this:

That’s it! We’ve finished another sketch. This is how it should look like:

Don’t forget to save and name your project. Then Run it and place a ball in front of Wheelson and watch it outline the ball and write out it’s location on the screen.
If the project doesn't work when you try to Run it, go through the sketch one more time.