Synchronous Serial Labs

Lab: I2C Communication with a Time-of-Flight Distance Sensor

I2C stands for inter-intergrated circuit and is a type of synchronous serial communication. I2C only uses 2-wires to communicate data between the two devices. One wire is the data line and one wire is the clock line, by allowing input and output to move across both of these lines.

Despite the simplicity of the wiring I did initially run into an error.

Error message in serial monitor

As the error message suggests, I had wired incorrectly. Since the pins are labeled on the backside of the breakout board I got a couple mixed up. Once that was rectified the values from the sensor started rolling in.

Underside of sensor

Correct wiring for Time-of-Flight Distance Sensor

Lab: SPI Communication With A Digital Potentiometer

This lab uses synchronous serial communication to send information between a digital potentiometer chip and Arduino. This exchange is done through a Serial Peripheral Interface (SPI) protocol. SPI’s use four wires to communicate back and forth.

Initially, with this lab I got the speaker to play a tone, but the loudness was not adjusting at all. I checked the wiring and it all looked good. I spoke with Leia who had just finished the same lab and had the same problem. I reread the lab in an effort to make sure I was clear on what mechanisms were involved in controlling the tone. I confused myself a bit, then attempted one change. In the code, I changed one line:

const int CSPin = 10; // chip select pin number <<original const int CSPin = 9; // chip select pin number << changed

When I made this change the speaker’s loudness did start to go up and down. The sound was less smooth and very sputtery but it was fluctuating. I thought I had solved the problem and could work backwards in order to understand why CSPin should be 9 and not 10, but as far as I can tell CSPin = 10, because Arduino’s D10 pin is connected to the potentiometer’s CS. I then tried a few other numbers. When CSPin = 8 or 11, I get the same results as 9. In the end what I do know is the CSPin should be 10. What I’d like to know is why when CSPin = 10, the loudness of the tone does not fluctuate.

Previous
Previous

AR Animation

Next
Next

Lab: Serial Input and Output w/ p5.js