For this week in physical computing, I completed the labs with Martin and Patrick from our class. While I have performed the previous labs on my own, I enjoyed working in a group. Whenever we had issues with debugging, we bounced off ideas from each other. Additionally, physically speaking to students helped reinforce the concepts in my head. We first began with the lab “Intro to Asynchronous Serial Communications.”

Breadboard attached to an accelerometer and a pushbutton

I borrowed an accelerometer from the ER. The X and Y axis pins are attached to the Nano’s analog pins 0 and 1 respectively. I learned more about the Arduino Serial Monitor in order to view and analyze incoming serial data. I learned about the difference between ASCII and raw binary data. While Serial.println() formats values as an ASCII-encoded decimal number, Serial.write() sends a binary value of the sensor reading.

Garbage letters

When we accidentally used Serial.write() instead of Serial.println(), we received garbage letters because Serial.write() does not translate bytes into ASCII characters. Understanding the methods in which serial communication are organized between my computer and microcontroller is fascinating. I hope to connect some of my previous p5.js sketches to my breadboard.

Accelerometer demonstration

Our accelerometer gave us readings between about 0 and 150.


When we used Serial.println(mappedValue), we received more in-depth information. The sketch printed the raw binary value, the ASCII-encoded binary value, and then the ASCII-encoded decimal, hexadecimal, and octal values. The more I learn about coding, the more I realize the importance of staying organized and understanding what each value represents. I wonder when I will need hexadecimal and octal values.

The lab “Serial Input to P5.js was a lot of fun. We connected a potentiometer to a p5.js sketch and mapped the values.

Potentiometer connected to my breadboard

I found that the names of the serial ports are intuitive. I feel comfortable setting up callbacks for close, open, and error. Sometimes I would run into the error message “port is busy.” I cannot change my Arduino code while my sketch and p5.serialcontrol are open.

Background color changes

In the draw function, we printed the sensor value to the screen. Then, my group changed the background rgb values to be between 0 and 255.

Our graph

Finally, we created the function graphData(). The value from the potentiometer is mapped as a number value.

As a personal project, I am working on a pushbutton that is connected to my previous sketch:

In my Arduino code, I created four if statements that detect the state of the button change when it is pressed. I am figuring out how to send the data from my breadboard to my sketch in order to change the state of my cat button.

Image result for ouija board

For my midterm, Filmon and I decided to create an interactive ouija board. Our initial plan was to have each letter appear on a monitor, but this goal may be too challenging. Instead, we may have the “Yes” and “No” be connected to giant LED lights as switches. Vibrations would occur when the planchette touches the alphabet. I look forward to discussing our ideas more tomorrow during office hours.