Learn how to use Blocky Coding Platform
In this workshop, you will explore the basics of robotics by learning how to use the Otto Software interface to communicate with your bot. Working in teams of three, you will practice the "upload" process to send commands from your computer to the Arduino Nano, bringing your Otto Bot to life. Through this hands-on experience, you will develop essential Computer Science and Collaboration skills as you troubleshoot code and see your programming turn into real-world movement.
This workshop assumes that you have covered Introducing Otto Hardware.
Material List
Set up
Let’s get started in setting up and getting familiar with the blocky block based coding app.
Download Blocky for Free
You can get the app on your own personal device by clicking on Windows software
Open Blocky
Once you have the Blocky software open let’s take a look at the interface
To the left you will see the different blocks we can use organized by function
We will use:
- Structure
- Robot
- Buzzer
- Timing
- đź‘€ LED Matrix
- Control
Structure
Let’s set up our base for our code:
- Click on Structure
- Select Setup and Loop block and drag it to our workspace
Setup
Setup is the part of our code where we introduce what we are working with, where they are and what their starting state is. Think of it as when you met someone new. You let them know your name, where your from and how your feeling.
Loop
Loop is the part of your code where most things happen. Now that we know what we are working with, what do we want to do with those parts.
Robot
Now that we have our base, let introduce our components to the blocky We are starting with 4 servos. These 4 servos will be used for our legs of the robot.
- Click on Robot
- Click on Legs
- Select the top block biped and drag to workplace
- Where should this go?
- In this block we are introducing the servos that make up our legs
- so the block goes in set up.
Setup Servos
You will see here that we have a number associated with each limb. This number is the location of where that servo is on our hardware (pins 2-5). We also have our buzzer setup here as well in pin 13.
Remember when we set up our buzzer and servos onto our shield? This is where placement matters so that the code can find the components.
Programming the servos in first allows for us to have our servos ready when we fully assemble our robot.
Heading back to the code, let’s add the home block for the legs
- This will set all servos to their home position
- For us that will mean that Otto is standing
- Once uploaded on to our servos, the servos will be ready to be added to the body of our robot
Buzzer
Before uploading our code let’s also add in our buzzer.
As mentioned the biped setup code introduced our buzzer to pin 13. With that we can add our actions to the loop.
Loop Buzzer
Here I selected the starwars song. This song will now play on repeat when we upload our code….
Let’s give ourselves a bit of a break by adding in a pause.
Timing
Here we can select our “wait number of seconds block”.
- Where does this go?
- Well if we want a break after the song we can put this after the buzzer plays.
Loop Time
Here I have added the wait and updated the wait time to 5 seconds.
Now that this is set lets upload our code and see what happens.
Labeling each servo after you program will help keep track of what servo was connected where in case you need to take your circuit apart.
Upload
Now that we have starting block code ready to go let’s upload to our Arduino nano!
USB connect
- First let's plug in our USB into our computer and the mini USB into our Arduino Nano
- Next head to the upper right hand corner. Select “select UBB” and choose the USB port that pops up.
- finally click on the green arrow to upload code
Once the code has uploaded you will hear the music start to play.
👀 LED Matrix
Setting up Matrix
- Now that we have sound lets add some expressions to our code with the LED Matrix.
- Head LED Matrix Block code section.
- Scroll down until you see “TM1640 matrix”
- Select and drag “TM1640 matrix” to our workspace
Modify TM1640 Matrix
- Now that we have our matrix block we will need to update the location of each pin
- Our SDA pin will be filled in for DIN (SDA = DIN)
- DIN=10
- While our SCL pin will be filled in for CLK (SCL = CLK)
- CLK = A5
Loop our matrix
- Now that we have set up our Matrix, now we can add some LED functionality to our code
- Head to the LED matrix block code and pick or create an expression
Here I have added eyes1 to our loop
Once you are finished, run your code by selecting the green arrow. You will now see our Matrix LED eyes pop up.
If you want your eyes to change try adding a different eye setting and a delay (wait) for how long you want it to stay on.
Servo: Walking
Last we will give our robot a little movement with the servos.
We have already setup and homed our legs to in theory they are set to stand.
Head to Robot-Legs block code and pick a movement. Drag and drop on to workspace and run.
Robot test
Now that we have tested this out on our loss parts- lets see what this would look like on our full robot.
Plug in the mini usb into the back of the robot and run code.
You will now be able to see how the servos allow our robot to move.
Optional: Control
If you want your robot to repeat an action you can copy and paste the command or head to Control.
Here we have the option to add conditions and repeat steps.
Optional: Arms
If you want to be able to move the arms of your robot make sure to add the set up for arms in your Setup section of your code.
Last ensure that you have set your arms to home in the set up or loop.
Required: Set to Home
Now that we are familiar with the code, lets build our robot following the Build a Bot: Otto Build Guide. Make sure to set servos to home, by running the following code, before building.
If using Arms run: