In this section we will discuss the available blocks in MakeCode, and what they do.

Transcript

Hi, welcome back to the Circuit Playground Express online workshop. In this section, we're going to talk about the different blocks available in MakeCode and how to use them.

So, if we look inside MakeCode the first category of blocks we have is lights and this is used to control the light ring on the Circuit Playground itself. So, this is probably our most used category. We can set the colours of lights individually, we can set animations, or we can have them react to things like live data, so one of the coolest features amongst the lights is probably the graph function, which graphs live data from one of your sensors, if you put live data in there, as a bar graph that's translated in real-time onto the light ring. We're going to also do things like set the brightness, create a photon animation manually and one of the most important blocks in this category I would say, would be the clear, so that's how you turn the lights off. When you set lights to turn on and the program ends the lights will stay on indefinitely, until you command them off. Now whenever you click on lights underneath it another category appears for Neopixels and this is how we would interact with strips that are connected to the Circuit Playground externally. So, if we wired additional lights onto the board we control them with these blocks.

The next category that we have is input blocks and I talked to you about this in the input/output section, but just to go over it again quickly for you. There's event blocks and at the top and these work a lot like an if conditional, so whatever the condition at the top is met they'll run the code that's inside them and we have our live data which are the bubbles, which are bringing live raw data from the sensors that you can then interact with, whichever way you like.

The next section that we have is music, so this is how we play our different tones, we have some that play pre-packaged sounds and then somewhere we can select the tones ourselves from a little keyboard on the screen and we also have pause blocks, rests. So, we can create more interesting tunes by creating breaks.

The next section that we have in our network section. So, this is how we use our infrared transmitter and a receiver on the board to either send signals to external devices or communicate with two Circuit Playground Expresses. The easiest way to use it using MakeCode is to communicate from one Circuit Playground Express to another and is quite reliable so you can send a number from one Circuit Playground Express and if they have this infrared received block and their received the given number that they expect to receive then it can run a certain type of program on their Circuit Playground Express.

We have our loops which is where our main body of code fits into. The forever loop is where all our main code will fall inside, we have our pauses which are important, the on start which is great for setup operations, like setting the brightness of your LEDs and we have loops, like repeat four times or our "while" loops and us "for" loops and a different type of "for" loop "Element" loop.

So, within our logic, we've talked about our diverse types of logic in the programming logic section of this workshop. We have our "if" statements our "comparisons" and our "Boolean" logic.

Variables only appear when, we have something that uses a variable already in the code or if we make a variable ourselves. So, using these blocks is how we would set a variable to a given number or change that variable by something and then the bubble is how we would use whatever the variable is.

Our last section is math, which is exactly what it sounds like. That's where we can get our math functions to change our variables up however we want, to make them work for the code better.

So that wraps up this section on the different blocks available in MakeCode. Stick around for the next section, I'm going to talk to you about the advanced blocks and how to use them.

Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.