Arduino Questions and Answers – Serial and Stream Communications

This set of Arduino Interview Questions and Answers for freshers focuses on “Serial and Stream Communications”.

1. How many RX-TX pairs of pins are present in the Arduino Mega?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: d
Explanation: The Arduino Mega has 3 RX-TX pairs; 0&1, 19&18, 17&16 and 15&14. The Serial pins are used for establishing and maintaining communications between the computer and the Arduino. However, once any of these RX-TX pairs are setup for serial communications, during the course of the program they cannot be used for GPIO.

2. What is the full form of UART?
a) Universal Asynchronous Receiver/Transmitter
b) Universal Anti-Rectifying Transmitter
c) Universal Asynchronous Radio Transmitter
d) Universal Asynchronous Rectifier Transistor
View Answer

Answer: a
Explanation: The UART architecture is a very important part of Serial Communications. It is not a protocol like the I2C or SPI, but a physical circuit configuration. Serial communication uses the UART architecture to send and receive the data serially from the computer.

3. In Serial Communications, how many sections is a data packet divided into?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: d
Explanation: The data packet is divided into 4 sections. The first section being the start bit which is usually 1. After that comes the data frame which holds the data which can range from being 5-bits to 9-bits. The section after the data section comes the parity section which denotes whether the number of bits in the data packet is odd or even. The final section is the stop-bit. This section can hold upto 2 bits and is used to indicate the end of the data packet.
advertisement
advertisement

4. Does the UART Architecture require an external clock?
a) Yes
b) No
View Answer

Answer: b
Explanation: UART stands for Universal Asynchronous Receiver/Transmitter. This means all communication here is not governed by the presence of a clock unlike the I2C and the SPI protocol which require an extra pin for performing serial communications.

5. What is the purpose of the following code?

Note: Join free Sanfoundry classes at Telegram or Youtube
  1. void setup() {
  2.     Seria.begin(9600);
  3. }
  4. void setup() {
  5.     Serial.write(40);
  6. }

a) Send a byte with value 40 through the Serial pins
b) Send a signal to pin 40 on the Arduino board
c) Send a hexadecimal number of 40 through the Serial pins
d) Send a octal number of 40 through the Serial pins
View Answer

Answer: a
Explanation: The above code uses the serial pins on the Arduino Board. The data is sent in the form of a byte whose value is 40. This data is processed into a data packet where the additional sections are added to number 40 and then send using UART.
advertisement

6. What is the function in Arduino that is capable of reading Strings from a stream and store the acquired value into a String?
a) Stream.readstring()
b) Stream.stringread()
c) Stream.readString()
d) Stream.readfromstring()
View Answer

Answer: c
Explanation: The Stream.readString() is a function that belongs to the Stream class. It’s capable of reading any String from a stream and then store the output into a String. This function can also be called from the Wire class. There is a timeout for this reading which is defined by the setTimeout() function.

7. What is the function of the readBytesUntil() function?
a) Reads only integers from a stream
b) Reads any characters from a stream
c) Reads only special characters from a stream
d) Tokenizes a string from a stream
View Answer

Answer: b
Explanation: The readBytesUntil() function belongs to the Stream class. It is used for reading any characters from a stream. The function continues to read characters entered until the termination character is found. It then puts all the collected data into a buffer.
advertisement

8. What is the maximum number of arguments does the find() function accept?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: b
Explanation: The find() function accepts a maximum of 2 parameters; the target which can be a set of characters, and the length of the target which denotes the lexical length of the target. This function then searches for the target throughout the stream and returns a Boolean True if a match is found, otherwise a Boolean False if the target is not found.

9. How many parameters does the flush() function accept?
a) 0
b) 1
c) 2
d) 4
View Answer

Answer: a
Explanation: The flush() function is a member of the stream class. The function exists to clear every character that is stored in the buffer. It accepts no arguments since it clears the entire buffer unconditionally on being invoked, so no parameters are required to carry out this operation.

10. What is the default time limit that is set automatically if no value is passed as the limit to the setTimeout() function?
a) 100 milliseconds
b) 1500 milliseconds
c) 1000 milliseconds
d) 2432 milliseconds
View Answer

Answer: c
Explanation: The default time limit is set to 1000 milliseconds before the setTimeout() will wipe the data from the buffer if no time limit is provided externally. This function has no return data type, and can be invoked from a host of functions.

Sanfoundry Global Education & Learning Series – Arduino.

To practice all areas of Arduino for Interviews, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.