You are on page 1of 5

Creative Design and Innovation (CDI)

Grade 12 Advance
Week 3 – Assessment Checkpoint - CA

Instruction: Complete all Parts (1-3), then submit back to your teacher, through LMS.
Part 1 of 3: Fill in your student details (in English):
Student ID. /‫رقم ال ّطالب‬ Enter your Student ID
Student Name /‫اسم ال ّطالب‬ Enter your Student Name
School Name ‫ اسم المدرسة‬/ Enter your School’s name.
Grade & Stream /‫صف والمسار‬
ّ ‫ال‬ 12 General ّ ‫ال‬
Class / ‫شعبة‬ Enter your class
Subject /‫المادّة‬ Creative Design and Innovation Date / ‫تاريخ‬

Q1. What is a function in programming? (2 marks)


segments of code to perform

individual tasks.
Part 2 of 3: Answer the questions in this part as per the given instructions.
Q2. The image below shows an example of a function with its part labelled as A – D.

B C

Complete the table below by writing the correct name for parts A – D shown above.
(4 marks)
A Data type of function

B Name of the function

C parameters

CDI / 12 Advance / Week 3 / CA Page 1 of 5 Term 3 (2019-20)


D Body of the function
Q3. Consider the Arduino code below.
int x = 4;
int y = 12;
char z;

void setup() 
{
  Serial.begin(9600);
 
z = comparison(x, y); 
Serial.print("The comparison result is - ");
Serial.println( z );
}

void loop() 
{
}

char comparison (int x, int y) 
{
  char result;
if (x>y)
{
result = ‘T’;
  }
else
{
result = ‘F’;
}
return result;
}
(a) Complete the table below to identify the two global variables and one local variable used in the
Arduino code above. (6 marks)
An example is done for you.

No. Type of Variable Name of the variable used in the code

1. Global z

2. Global x

3. Global y

4. Local result

CDI / 12 Advance / Week 3 / CA Page 2 of 5 Term 3 (2019-20)


(b) Write the above-mentioned code in Arduino IDE by completing the actions as mentioned below:
(i) Assign value 70 to x
(ii) Assign value 13 to y
(iii) Change the ’comparison‘ function’s datatype and return variable data type ’result’ to boolean.

Then, paste a picture of the code in the space given below: (8 marks)

(c) What is the output of the code mentioned in 2(b)? (2 marks)


Paste a picture of the output you see on your serial monitor.

Q4. Consider the circuit connection given below:

CDI / 12 Advance / Week 3 / CA Page 3 of 5 Term 3 (2019-20)


Complete the Arduino code below as mentioned in the comments. (8 marks)
int buttonState = 0;
void setup()
{
pinMode(2, INPUT);
pinMode(13, OUTPUT);
}
void loop()
{
//call the function to turn the LED ON / OFF which you will write below
blinkBybutton();
}

/* write a function that –


 reads the pushbutton’s value and stores it in variable ‘buttonState’
 turns the LED ON if pushbutton is pressed and wait for 1 second

CDI / 12 Advance / Week 3 / CA Page 4 of 5 Term 3 (2019-20)


 turns the LED OFF if pushbutton is released and wait for 1 second */
void blinkBybutton()
{
buttonstate = digitalRead(2);
if (buttonstate == 1)
{
digitalWrite(13, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
}
else
{
digitalWrite(13, LOW);
delay(1000); // Wait for 1000 millisecond(s)
}
}
Part 3 of 3: Save this completed document, then submit back to your teacher through LMS:
Save your file using the naming convention: ‘W3- <your student id>.docx’
For example, if your student id is 25678, then your file name would be: W3 - 25678.docx
_______________________________________________________________________

Submit back to your teacher through LMS. (lms.moe.gov.ae)


Total Marks Click or tap here to enter text./ 30

CDI / 12 Advance / Week 3 / CA Page 5 of 5 Term 3 (2019-20)

You might also like