Lesson 6: If

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			}		}	]}