Table of Contents

6.2 BLOX: Events and Logic

Using BLOX to build firmware is like piecing together a puzzle where each piece represents a different action or decision your device needs to make. Here’s a simple way to understand it:

6.2.1 Everything Happens Sequentially

6.2.2 Logic Flow Control

By arranging these blocks in the workspace, you're essentially building a set of instructions that the firmware will follow, making your device do exactly what you want it to do.

6.2.3 Sequential Instructions

Let's start with a very basic example.

Your BLOX has two onboard RGB LEDs. Let's setup a simple program to control these LEDs. No inputs, no change to the flow of the program. Just a set of instructions executed sequentially.

Once it starts to run the firmware we want to: If we build this out in BLOX it would look like this:

- Set both LEDs to RED
- Wait for 1 second
- Set both LEDs to GREEN
- wait for 1 second
- Set both LEDs to BLUE
- wait for 1 second
- Then repeat (the pattern will run over and over)

It's really that easy! You can substitute the LEDs for any other output and already build out a couple interesting projects

6.2.4 Control flow of Instructions using a Logic block

Let's expand upon our basic example

Lets add a little logic to the program. Suppose we only want the LED pattern to run, if a certain condition is being met. For the sake of simplicity, lets use the onboard MODE button as an input. We only want the program to run if the MODE button is pressed, otherwise, just turn the LEDs Purple.

Once it starts to run the firmware we want to: If we build this out in BLOX it would look like this:

IF the button is pressed:
- Set both LEDs to RED
- Wait for 1 second
- Set both LEDs to GREEN
- wait for 1 second
- Set both LEDs to BLUE
- wait for 1 second
ELSE
- set the LEDs to Purple

You can apply this exact concept to a lot of other examples