The learner will review code and answer questions about an analog read.

Analog Input Reading

All the flashcards in this set deal with the following code:

/*Assume a 10 bit analog to digital converter. Assume maximum analog input is 5 VDC. Thus a 5 volt input would be read as 1023, a 2.5 volt input would be read as 512, and a 0 volt input would be read as 0. */

int analogPin = 1;
int value = 0;

void setup()
{
   Serial.begin(9600);
}

void main()
{
   value = analogRead(analogPin);
   Serial.println(value);
}

The code is displayed in the image below, which will be on each card, but you may want to make note of it before going on.

Question Image
Question 1 of 10

Analog Input Reading

Correct!

All the flashcards in this set deal with the following code:

/*Assume a 10 bit analog to digital converter. Assume maximum analog input is 5 VDC. Thus a 5 volt input would be read as 1023, a 2.5 volt input would be read as 512, and a 0 volt input would be read as 0. */

int analogPin = 1;
int value = 0;

void setup()
{
   Serial.begin(9600);
}

void main()
{
   value = analogRead(analogPin);
   Serial.println(value);
}

The code is displayed in the image below, which will be on each card, but you may want to make note of it before going on.

question image

Correct Answer

Got it!

 Next Question
Question 1 of 10

Analog Input Reading

Incorrect

All the flashcards in this set deal with the following code:

/*Assume a 10 bit analog to digital converter. Assume maximum analog input is 5 VDC. Thus a 5 volt input would be read as 1023, a 2.5 volt input would be read as 512, and a 0 volt input would be read as 0. */

int analogPin = 1;
int value = 0;

void setup()
{
   Serial.begin(9600);
}

void main()
{
   value = analogRead(analogPin);
   Serial.println(value);
}

The code is displayed in the image below, which will be on each card, but you may want to make note of it before going on.

question image

Your Answer

Correct Answer

Got it!

 Next Question
Question 1 of 10

Analog Input Reading

Which analog input channel is read?

Question Image
Question 1 of 10

Analog Input Reading

Correct!

Which analog input channel is read?

question image

Correct Answer

1

Explanation:

The line value = analogRead(analogPin); calls the analogRead function on the value stored in analogPin.  That value was set to 1.

 Next Question
Question 1 of 10

Analog Input Reading

Incorrect

Which analog input channel is read?

question image

Your Answer

Correct Answer

1

Explanation:

The line value = analogRead(analogPin); calls the analogRead function on the value stored in analogPin.  That value was set to 1.

 Next Question
Question 1 of 10

Analog Input Reading

The analogRead function accepts which type of argument?

Question Image
Question 1 of 10

Analog Input Reading

Correct!

The analogRead function accepts which type of argument?

question image

Correct Answer

Integer

Explanation:

The analogRead function takes an integer argument.

 Next Question
Question 1 of 10

Analog Input Reading

Incorrect

The analogRead function accepts which type of argument?

question image

Your Answer

Correct Answer

Integer

Explanation:

The analogRead function takes an integer argument.

 Next Question
Question 1 of 10

Analog Input Reading

Assume 2.5 VDC is applied to analog input 2 and we run the program.  What number will value have?

Question Image
Question 1 of 10

Analog Input Reading

Correct!

Assume 2.5 VDC is applied to analog input 2 and we run the program.  What number will value have?

question image

Correct Answer

unknown

Explanation:

Since our program is not reading from analog input 2, we would need to know the input, if any, on input 1 to know what value the variable value will have.

 Next Question
Question 1 of 10

Analog Input Reading

Incorrect

Assume 2.5 VDC is applied to analog input 2 and we run the program.  What number will value have?

question image

Your Answer

Correct Answer

unknown

Explanation:

Since our program is not reading from analog input 2, we would need to know the input, if any, on input 1 to know what value the variable value will have.

 Next Question
Question 1 of 10

Analog Input Reading

Which input would analogRead attempt to read in this code: analogRead(analogPin + 3);

Question Image
Question 1 of 10

Analog Input Reading

Correct!

Which input would analogRead attempt to read in this code: analogRead(analogPin + 3);

question image

Correct Answer

4

Explanation:

It would try to read input 4 since analogPin = 1, digitalRead(analogPin + 3) is the same as digitalRead(1 + 3) which is digitalRead(4).

 Next Question
Question 1 of 10

Analog Input Reading

Incorrect

Which input would analogRead attempt to read in this code: analogRead(analogPin + 3);

question image

Your Answer

Correct Answer

4

Explanation:

It would try to read input 4 since analogPin = 1, digitalRead(analogPin + 3) is the same as digitalRead(1 + 3) which is digitalRead(4).

 Next Question
Question 1 of 10

Analog Input Reading

The Serial.println command prints the numerical content of the variable value in this program.  If 1.25 VDC is applied to analog input 1, what value would be printed?

Question Image
Question 1 of 10

Analog Input Reading

Correct!

The Serial.println command prints the numerical content of the variable value in this program.  If 1.25 VDC is applied to analog input 1, what value would be printed?

question image

Correct Answer

256

Explanation:

Since the maximum analog input is 5 VDC which gives a reading of 1023, we can use a proportion to find the reading of 1.25 VDC.  .  Solving this proportion gives x is 255.75, which rounds to 256.

 Next Question
Question 1 of 10

Analog Input Reading

Incorrect

The Serial.println command prints the numerical content of the variable value in this program.  If 1.25 VDC is applied to analog input 1, what value would be printed?

question image

Your Answer

Correct Answer

256

Explanation:

Since the maximum analog input is 5 VDC which gives a reading of 1023, we can use a proportion to find the reading of 1.25 VDC.  .  Solving this proportion gives x is 255.75, which rounds to 256.

 Next Question
Question 1 of 10

Analog Input Reading

Which input would be read if we used the code analogRead(analogpin);?

Question Image
Question 1 of 10

Analog Input Reading

Correct!

Which input would be read if we used the code analogRead(analogpin);?

question image

Correct Answer

Compile error

Explanation:

The variable name analogpin is not defined.  Recall that variables are case sensitive.  

 Next Question
Question 1 of 10

Analog Input Reading

Incorrect

Which input would be read if we used the code analogRead(analogpin);?

question image

Your Answer

Correct Answer

Compile error

Explanation:

The variable name analogpin is not defined.  Recall that variables are case sensitive.  

 Next Question
Question 1 of 10

Analog Input Reading

What is the range of values analogPin can have in this example?

Question Image
Question 1 of 10

Analog Input Reading

Correct!

What is the range of values analogPin can have in this example?

question image

Correct Answer

0 to 1023

Explanation:

The analogPin variable could be any of the numbers from 0 to 1023.  Note that 1024 is outside the range of what can be read (since we only have a 10 bit converter).  

 Next Question
Question 1 of 10

Analog Input Reading

Incorrect

What is the range of values analogPin can have in this example?

question image

Your Answer

Correct Answer

0 to 1023

Explanation:

The analogPin variable could be any of the numbers from 0 to 1023.  Note that 1024 is outside the range of what can be read (since we only have a 10 bit converter).  

 Next Question
Question 1 of 10

Analog Input Reading

True or False: We could simplify the main function to the following single line: Serial.println(analogRead(analogPin));.

Question Image
Question 1 of 10

Analog Input Reading

Correct!

True or False: We could simplify the main function to the following single line: Serial.println(analogRead(analogPin));.

question image

Correct Answer

True

Explanation:

This would work (assuming we always wanted to print the value of analogPin instead of being able to easily comment that line out for when we are not debugging).  The line Serial.println(analogRead(analogPin)); would first read the value of pin number analogPin.  Then it would print that value.

 Next Question
Question 1 of 10

Analog Input Reading

Incorrect

True or False: We could simplify the main function to the following single line: Serial.println(analogRead(analogPin));.

question image

Your Answer

Correct Answer

True

Explanation:

This would work (assuming we always wanted to print the value of analogPin instead of being able to easily comment that line out for when we are not debugging).  The line Serial.println(analogRead(analogPin)); would first read the value of pin number analogPin.  Then it would print that value.

 Next Question
Question 1 of 10

Analog Input Reading

True or False: In this example, value could have been of type Char (an 8-bit data type).

Question Image
Question 1 of 10

Analog Input Reading

Correct!

True or False: In this example, value could have been of type Char (an 8-bit data type).

question image

Correct Answer

False

Explanation:

A Char type would not be large enough to hold the 10-bit date created by the converter.

 Next Question
Question 1 of 10

Analog Input Reading

Incorrect

True or False: In this example, value could have been of type Char (an 8-bit data type).

question image

Your Answer

Correct Answer

False

Explanation:

A Char type would not be large enough to hold the 10-bit date created by the converter.

 Next Question
Question 1 of 10

Analog Input Reading

If we changed the code in the main function as written below, what would be printed if the analog input had 2.5 VDC applied to it?

Serial.println(value);
value = analogRead(analogPin);

Question Image
Question 1 of 10

Analog Input Reading

Correct!

If we changed the code in the main function as written below, what would be printed if the analog input had 2.5 VDC applied to it?

Serial.println(value);
value = analogRead(analogPin);

question image

Correct Answer

0

Explanation:

Since we set variable value = 0 when we initialized it and we are printing it before it is assigned the value from the analogRead function, it will still be 0 and that is what will be printed.

 Finish
Question 1 of 10

Analog Input Reading

Incorrect

If we changed the code in the main function as written below, what would be printed if the analog input had 2.5 VDC applied to it?

Serial.println(value);
value = analogRead(analogPin);

question image

Your Answer

Correct Answer

0

Explanation:

Since we set variable value = 0 when we initialized it and we are printing it before it is assigned the value from the analogRead function, it will still be 0 and that is what will be printed.

 Finish
Question 1 of 10
Analog Input Reading

Score

You have answered 5 of 10 questions correctly.

50%

Start Over

See other flashcards and apps related to:

Question 1 of 10
Author
Published
6/2/2015
Last Updated
6/2/2015
Tags

No Comments Yet