This code begins with the timer function, which indicates that every 1 second, running infinitely, it will perform the indicated function. In this case, we have used the ‘If’ function, to indicate that if the position of the cube is two, a white LED will light up, we achieve this with the ‘if’ function and then with the then parameter, then we have used the ‘else’ function, in case it is not in position two, another LED lights up, but in this case black.
JSON code:
{ "do": [ { "timer": { "do": [ { "if": { "else": [ { "light": { "brightness": 100, "color": 0, "duration": 1, "led": 0 } } ], "is": [ "cubePosition", "==", 2 ], "then": [ { "light": { "brightness": 100, "color": 1, "duration": 1, "led": 0 } } ] } } ], "every": 1, "id": 0, "play": -1 } } ]}
Lesson 7: Variables
At the beginning of this code, what we are going to do at the beginning is to create a variable called ‘a’, which contains the amount ‘500’, and we achieve this with the parameter ‘=‘, within the ‘set’. Later we have added a timer that every second adds 10 to the variable ‘a’ and makes…