Search Header Logo
Arduino Exam Revision 2

Arduino Exam Revision 2

Assessment

Presentation

•

Computers

•

7th - 12th Grade

•

Medium

Created by

Bayden Schellein

Used 1+ times

FREE Resource

17 Slides • 16 Questions

1

Arduino Revision Part 2

2

media

Digital Pins

pinMode(13, OUTPUT);

This function is used to define digital pin
working behaviour. Digital pins are
defined as an input (INPUT) or an output
(OUTPUT).

In the example above you can see
brackets containing two parameters: the
variable (ledPin) and its behaviour
(OUTPUT).

3

media

pinMode

“pinMode” configures the specified
digital pin to behave either as an
input or an output.

It has two parameters:

“pin”: the number of the pin whose
mode you wish to set.

“mode”: INPUT, OUTPUT, or
INPUT_PULLUP.

4

media

DigitalWrite

The loop uses another function called
digitalWrite();

digitalWrite writes a HIGH (on) or a LOW (off)
value to a digital pin.

If the pin has been configured as an OUTPUT
with pinMode(), its voltage will be set to the
corresponding value: 5V (or 3.3V on 3.3V
boards) for HIGH and 0V (ground) for LOW.

In other words, by writing HIGH we turn on
the thing connected to that pin by sending it
power, and turn it off by writing LOW.

5

Multiple Choice

Question image

What is the correct pinMode setup code for this circuit?

1

pinMode(12, OUTPUT);

2

pinMode(8, INPUT);

3

pinMode(8, OUTPUT);

4

pinMode(7, INPUT);

6

Multiple Choice

Question image

If coded correctly, would the following circuit function?

1

Yes

2

No

7

Multiple Choice

Which means ON?
void setup()
{  
pinMode(13, OUTPUT);

}
void loop()
{  
digitalWrite(13, HIGH); 
  delay(1000);   
digitalWrite(13, LOW); 
  delay(1000); 
}
1
OUTPUT
2
HIGH
3
LOW
4
delay

8

Multiple Choice

Which command will turn the LED Off?
void setup()
{  
pinMode(13, OUTPUT);
}
void loop()
{  
digitalWrite(13, HIGH);    delay(1000);   
digitalWrite(13, LOW);    delay(1000); 
}

1
OUTPUT
2
HIGH
3
LOW
4
delay

9

Hotspot

This code has two errors in it. It should turn on an LED in pin 13 for 150ms. Point to the two errors.

10

LED's

Typically, LEDs have two leads, one positive and one negative. There are two ways to tell which is the positive lead of the LED and which the negative: Firstly, the positive lead is longer. Secondly, where the negative lead enters the body of the LED, there is a flat edge to the case of the LED.

media

11

LED's

LED's (Light Emitting Diodes) are polarised so they have to be connected the right way around. If you put the negative lead of an LED in to the power supply and the positive lead to ground, the component will not work, as can be seen in the diagram to the right.

media

12

Resistors

As the name suggests, resistors resist the flow of electricity. The higher the value of the resistor, the more resistance it has and the less electrical current will flow through it. The unit of resistance is called the Ohm, which is usually shortened to Ω( The geek letter Omega).

media

13

Does it matter where you place them?

Generally no. In most simple circuits all the components will be in what is called a series, where all components share the same voltage and current.

This means it does not matter if a resistor is placed before or after an LED (for example).

However, in most cases the resistor is placed before the LED to simplify circuit designs.

14

Multiple Choice

Question image

Would this circuit work if coded correctly?

1

Yes

2

No

15

Multiple Choice

Question image

Would this circuit, if coded correctly, work?

1

Yes

2

No

16

Multiple Choice

Question image

Would this circuit, if coded correctly, work?

1

Yes

2

No

17

Open Ended

Question image

This board should light up all the LEDs, but it does not. There are two issues.
Explain what each issue is and how to fix it.

18

Loops and Stuff

The arduino code has two sections:

VoidSetup - this runs once and contains any setup code like what pins we are using and what we are doing with them

VoidLoop - this run continually over and over again. it contains our main code.

19

For Loops

 The “for” statement is used to repeat a block of statements enclosed in brackets for a set number of repetitions.

An increment counter is usually used to go through each loop and stop the loop.

 

 There are four parts to the ‘for’ loop. Each is separated by a semicolon (;).

 

 

media

20

Multiple Choice

What is the primary purpose of using loops in programming?

1

To execute a set of instructions only once

2

To repeat a set of instructions multiple times until a condition is met

3

To store multiple values in a single variable

4

To increase the speed of the processor

21

media

22

Example

The variable i starts at 0 and counts, adding 1 to i after each loop until it is 5 or more, at which point the loop stops.

media

23

There are several to track a loop and control it.

This done with the variable and operators.

Operators are ways to change a variable with math.

Math Stuff
media
media

24

The top picture shows a list math operations the loop can check for.

The bottom picture shows a list of operators we can use for our increments.

Math Stuff
media
media

25

Example

The variable i starts at 0 and counts, adding 1 to i after each loop until it is 5 or more, at which point the loop stops.

media

26

Multiple Choice

Question image

How many times will the shown for loop execute?

1

0

2

9

3

10

4

11

27

The top picture shows a list math operations the loop can check for.

The bottom picture shows a list of operators we can use for our increments.

Math Stuff
media
media

28

Multiple Choice

Question image

What will the code do?

1

Print "Loop iteration!" only once

2

Print "Loop iteration!" three times

3

Run forever and print "Loop iteration!" continuously

4

Cause an error because loop() is empty

29

The top picture shows a list math operations the loop can check for.

The bottom picture shows a list of operators we can use for our increments.

Math Stuff
media
media

30

Fill in the Blanks

media image

What will this code print out?

Type in the sequence with only spaces in between the numbers.
​ ​ ​ ​ ​

31

Fill in the Blanks

media image

What will this code print out?

Type in the sequence with only spaces in between the numbers.
​ ​ ​ ​ ​

32

Drag and Drop

Create a for loop that counts down from 10 while the number is equal to or greater than 5, decreasing with 1 for each loop.



for (int ​
; ​
; ​
)
Drag these tiles and drop them in the correct blank above
i = 10
>= 5
i--
i = 5
<=5
i++
=5

33

Open Ended

Question image

This code has an issue.

1) find the issue and explain what it is

2) suggest a fix and explain why it will work.

pattern-tertiary
Arduino Revision Part 2

Show answer

Auto Play

Slide 1 / 33

SLIDE