Module 6 · Practice

Practice questions

Three difficulty levels.

Section A — Easy

01

Name the two main functions in every Arduino sketch and say when each runs.

02

Match the function to its purpose:

(a) pinMode (b) digitalWrite (c) digitalRead (d) delay
03

What range of values does analogRead return on a standard Arduino Uno?

04

What does PWM stand for and what is it used for?

Section B — Medium

05

Write a sketch that flashes an LED on pin 9 every half a second.

06

Why do you usually add a small delay after detecting a button press in a latch program?

07

Write the code to read the value from a sensor on A0 and print it to the Serial Monitor every second.

08

Why can't you connect a small motor directly to a digital output pin? What would you use instead?

Section C — Hard

09

Write a sketch that turns an LED on pin 13 on when the LDR reading on A0 is below 300, and off otherwise.

10

Write a subroutine called flash(pin, times, ms) that flashes any pin a given number of times with a chosen delay. Show how you'd call it to flash pin 9 four times with 200ms gaps.

11

Design a "smart desk lamp": an LED's brightness should follow a potentiometer. Describe the wiring (in words) and write the loop().

Check answers
← Back Notes Next → Answers