3
Electrical Engineering Final Exam Choose the best answer for each question. 1. Which of these can an Arduino NOT be used for? a. controlling servos b. displaying analog inputs c. building robots d. an Arduino can be used to do all of these 2. What are the Arduino’s two main program structures? a. setup and loop b. main and setup c. loop and main d. int and setup 3. How many analog ports does an Arduino have? a. five, and they are labeled A1-A5 b. six, and they are labeled A0-A5 c. six, and they are labeled A1-A6 d. five, and they are labeled A0-A4 4. Which of these is a digital input device? a. pressure sensor b. servo c. button d. potentiometer 5. Which of these is an analog input device? a. pressure sensor b. servo c. button d. LED 6. Which of these is an output device? a. pressure sensor b. servo c. button d. potentiometer 7. What command would you use to tell the Arduino that there is an output on port 9? a. int sensorPin = 9; b. int sensorValue = 9; c. digitalWrite(9, HIGH); d. pinMode(9, OUTPUT); 8. What command would you use to light up an LED on port 5? a. int sensorPin = A0; b. int sensorValue = 0; c. digitalWrite(5, HIGH); d. pinMode(5, OUTPUT);

Ee Final

Embed Size (px)

Citation preview

Page 1: Ee Final

Electrical Engineering Final Exam Choose the best answer for each question.

1. Which of these can an Arduino NOT be used for?a. controlling servosb. displaying analog inputsc. building robotsd. an Arduino can be used to do all of these

2. What are the Arduino’s two main program structures?a. setup and loopb. main and setupc. loop and maind. int and setup

3. How many analog ports does an Arduino have?a. five, and they are labeled A1-A5b. six, and they are labeled A0-A5c. six, and they are labeled A1-A6d. five, and they are labeled A0-A4

4. Which of these is a digital input device?a. pressure sensorb. servoc. buttond. potentiometer

5. Which of these is an analog input device?a. pressure sensorb. servoc. buttond. LED

6. Which of these is an output device?a. pressure sensorb. servoc. buttond. potentiometer

7. What command would you use to tell the Arduino that there is an output on port 9?a. int sensorPin = 9;

b. int sensorValue = 9;

c. digitalWrite(9, HIGH);

d. pinMode(9, OUTPUT);

8. What command would you use to light up an LED on port 5?a. int sensorPin = A0;

b. int sensorValue = 0;

c. digitalWrite(5, HIGH);

d. pinMode(5, OUTPUT);

Page 2: Ee Final

9. How would you pause a program for 2.5 seconds?a. delay(2500)

b. int sensorValue = 0;

c. delay(2.5);

d. pinMode(ledPin, OUTPUT);

10. How do you read values from the Arduino on the computer screen?a. the ‘View’ buttonb. the ‘Serial Monitor’ buttonc. the ‘Upload’ buttond. you cannot read values from the Arduino on the screen

11. What is the command for playing a musical note on the Arduino?a. tone();

b. play();

c. note();

d. sound();

The questions in the next section are answered by referring to the following program: 1 int sensorPin = A0;

2 int ledPin = 13;

3 int sensorValue = 0;

4 void setup() {

5 pinMode(ledPin, OUTPUT);

6 }

7 void loop() {

8 sensorValue = analogRead(sensorPin);

9 digitalWrite(ledPin, HIGH);

10 delay(sensorValue);

11 digitalWrite(ledPin, LOW);

12 delay(sensorValue);

13 }

12. What is the purpose of line 4?

a. To begin the setup program structureb. To begin the loop program structurec. To set the input value of port 13 to ‘ON’d. line 4 has no function in the program

13. What is the purpose of line 9?a. Turns off the LED plugged into pin 0b. Turns on the LED plugged into pin 13c. Turns off the LED plugged into pin 13d. Turns on the LED plugged into pin 0

14. What is the purpose of line 5?a. To begin the setup program structure.

Page 3: Ee Final

b. It turns on the LED plugged into port 13.c. To set port 13 to an output.d. Line 5 has no function in the program.

15. What does this program do when it is uploaded to the Arduino?a. It blinks an LED based on the value of an analog input.b. It writes the value of an analog input to the screen.c. It changes the brightness of an LED based on the value of an analog input.d. It blinks an LED, with no input from analog sources.