PCM Wk 6: Asynchronous Serial Communication Lab

Following along with the Intro to Asynchronous Serial Communication Lab.

1.) I used 2 analog inputs sensors: a force sensing resistor and a potentiometer. I hooked up the Arduino accordingly, using a 1 kΩ resistor to connect to GND for the force sensing resistor.

arduino and breadboard with 2 analog input sensors

2.) Then, I ran a sketch with that has a “Serial.print(SensorValue)” statement in the code. Below is a video that shows both sensor values are being read properly in the Arduino’s serial port.



3.)  When using the terminal as a Serial port, I added a while loop because otherwise the terminal wouldn’t stop running the values of the sensors. (This was before I was able to get the ctrl-A ctrl-\ to work). Below is the updated code:

int x=0;

void setup() {

void loop() {
// read the sensor:
int sensorValue = analogRead(A0);
// divide by 4 to reduce the range to 0-255:
sensorValue = sensorValue / 4;
// send it:

// read another sensor:
int sensorValue2 = analogRead(A1);
//divide by 4 to reduce the range to 0-255:
sensorValue2 = sensorValue2/4;
//send it:

4.) I printed “Serial.println(analogValue)” to recieve the ASCII value from the serial port. Below is a video of the values reading as ASCII.
Note to self: Arduino’s serial port, no matter what will alway sprint ASCII. “Serial.print()” reads everything as ASCII encoded.


5.) I then wrote “Serial.write()” in the sketch, and received the garbage characters (as the text predicted). “Serial.write()” speaks in binary but the serial port think in ASCII, which is why we receiving the binary values in ASCII form. Below is a video example of “Serial.write()” sketch.


6.) Then I tried to send the data in multiple formats. Below is a video of that.


7.) Wrote a program that reads the 2 analog sensors, following the format of the code given in the lab. I had a hard time trying to get the commas in the right place, but eventually realized that the “Serial.print(“,”)” could be placed outside of the else() statement. I wrote this code before realizing that there was a solution already in the article. Below is the code that I came up with:

” void setup() {
pinMode(2, INPUT);

void loop() {
int pushButton = digitalRead(2);

for (int thisSensor = 0; thisSensor < 2; thisSensor++) {
int sensorValue = analogRead(thisSensor);
// if you’re on the last sensor value, end with a println()
// otherwise, print a comma
if (thisSensor == 1) {
Serial.println(pushButton, BIN);

Sharing video of the serial port as well.




1.) When typed the less command into the mac terminal, I got an error:
/dev/cu.usbmodem1421 is not a regular file (use -f to see it)” Why?

2.) Tried to follow along with the “Using the Command Line for Duplex Communication.” I typed in the “screen /dev/cu.usbmodem-1421” and “control-A control-\” but it kept telling me it “Sorry could not find a PTY.”

*** Update: By checking this forum made it work by typing in “screen /dev/tty.usbmodem1421 9600″ instead of “screen /dev/cu.usbmodem-1421”

*** Update: also realized “control-A control-\” means actually using the key “ctrl” not typing in “control.”

3.) What is the difference between a “carriage return” and a “new line”? What does the “carriage return” mean?

4.) “For the handshaking it was mentioned that asynchronous serial communications could run into the problem that the sender could send faster the receiver. As a result, the receiver program slows down as the serial buffer fills up.” I am confused about this, because both the sender and receiver agreed upon the baud rate. So why is one faster than the other? Why do you need flow control?

5.) For handshaking portion, what changes the value of “Serial.available()” and makes it bigger than one? How is related to the “send” button? Is it related to the “send” button? Can we go over “Serial.available()” and “Serial.read()” more?

6.) Still not able to get Cool Terms to work, (note to self) will need to check in with someone/ resident about this.