## Introduction: Make a Connected Dice With TimeSquAir

Use an NFC tag to launch a dice

## Step 2: Go on Node-RED:

First create a new work-space, then add the node «Go» to begin. Add a function a write the following code on the first image.

A litle explanation of the code, you have two variables «max» and «min», the soustraction of the max and the min correspond to your interval. Then «Math.floor» will cast the number into an Integer, «Math.random» a number between 0 or 1 randomly, so it'll do something like this:

Math.random()= 0,849488…

0,849488 * (7-1) = 5,096928

5,096928 + 1 = 6,096928

Math.floor(6,096928) = 6

After that add the node «switch», then make correspond the number you gets randomly to the picture of the dice.

## Step 3: Import Images on the TimeSquair:

You'll need a File Transfer Protocol (FTP) like FileZilla who's using here. Open FileZilla and fulfill the parameters (Host, id, password and port). On the right panel you arrived on the root repository of the raspberry pi. Reach back into the repository by clicking on the “double dots”.

Then go in media.

On the left panel go in the repository where your images are. Then right click on the image and click on “send”.