Asynchronous Serial Communication Quiz 4

1. When two computers communicate using asynchronous serial communication, there are properties that they must both agree upon in order to communicate. What are those properties?

  • the rate at which data is sent and read
  • the voltage levels representing a 1 or a 0 bit

 

2.How many applications can access a given serial port on your computer at a time?

1 at a time.

 

3.The following error messages are from three different programs that can access a computer’s serial port. They all indicate the same problem. What’s wrong?

The port could only be used in one program. The other programs would deny access.

 

4.What are the two most common ways to interpret incoming asynchronous serial data?

ASCII and binary.

 

5.What are the relative advantages and disadvantages of these two methods?

ASCII
– pros: It can included different characters in readable format.
– cons: It takes time and bytes to send serial data

Binary
– pros: easy message and faster time to send serial data
– cons: one sensor at a time

 

6.The Arduino IDE’s serial monitor, like most serial terminal programs, uses one of these two methods to interpret incoming bytes. Which does it use?

ASCII

 

7.Here’s the output from a serial terminal program (Coolterm). What might you assume about the format that the sending device is using?

Binary

 

8.When sending data from one computer to another, what is the maximum range of values that you can fit into a single byte

 

8 bits = 256

 

9.How would you serially transmit a value that’s larger than the maximum value that can fit in a byte?

 

By convert a byte’s raw value to the ASCII characters representing it

 

10.Write a program to read an analog input on an Arduino and send the result serially to a desktop computer in a single byte.

 

void setup(){

  Serial.begin(9600);

}

void loop(){

  int analogValue = analog(A0);

  int mappedValue = map (analogValue, 0, 1023, 0 ,255);

 Serial.println(mappedValue);

}

 

11.Write a program to read three analog inputs on an Arduino and send the results serially to a desktop computer as an ASCII string, separated by commas, and terminated by a newline and carriage return.

 

void setup(){

  serial.begin(9600);

}

void loop(){

int sensorValue = analogRead(A0);

serial.print(sensorValue, BIN);

serial.print(‘,’);

int sensorValue = analogRead(A1);

serial.print(sensorValue, BIN);

serial.print(‘,’);

int sensorValue = analogRead(A2);

serial.print(sensorValue, BIN);

serial.print(‘,’);

}

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to Top