wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Arduino- Exercise 4 Random Dice

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

These are schematic symbols for a _____________

a)

LED

b)

Microcontroller

c)

Resistor

d)

Slide switch

2.

A variable is a number that ____________

a)

Changes

b)

Stays Constant

3.

When declaring a long variable we use the command _______

a)

int

b)

var

c)

long

d)

const

4.

Where in an Arduino sketch (programme code) do we declare variables and constants?

a)

At the end of the code

b)

At the top of the code

c)

Anywhere in the code

5.

random generates what type of numerical data?

a)

variable

b)

constant

6.

When deciding on variable names we use names that explain what is being stored. If we wanted do declare a 'long' variable that had something to do with light levels which name would you choose?

a)

switchstate

b)

randomlight

c)

lightlevel

d)

temperaturereading

7.

If we wanted a random number between 1 and 6, what command would we use?

a)

random (1, 6);

b)

random (1,7);

c)

Random (1, 8);

8.

If we wanted a random number between 2 and 10, what command would we use?

a)

random (2, 10);

b)

random (2,11);

c)

Random (1, 10);

9.

'if' is what type of command?

a)

declaration

b)

process

c)

conditional/decision

d)

input/output

10.

Tick the errors with this 'if' statement which displays 1 if random number selected is 1


if (randDice = 1){

digitalWrite(7, LOW);

digitalWrite(8, LOW);

DigitalWrite(9, HIGH);

digitalWrite(10, LOW);

digitalWrite(12, LOW);

digitalWrite(13, LOW);

{

a)

'if' is incorrectly written

b)

There should be two = signs used in 'if' statements.

c)

Closing curly bracket is the wrong way

d)

One of the digitalWrite commands is incorrectly written

e)

Two of the digitalWrite commands is incorrectly written