Jason's notes

Week8 Synchronous Serial


Lesson: https://itp.nyu.edu/physcomp/lessons/synchronous-serial-communication-the-basics/


  • a Serial Data In (SDI), on which the controller sends data to the peripheral devices.
  • a Serial Data Out (SDO), on which the peripheral devices send data to the controller.
  • a Clock (SCLK) connection, on which the controller sends a regular clock signal to the peripheral devices.
  • one or more Chip Select (CS) connections, which the controller uses to signal the peripheral devices when to listen to incoming data and when to ignore it.


  • a Serial Clock (SCL) connection, on which the controller sends the clock signal, just as in SPI
  • a Serial Data (SDA) connection, on which the controller and peripherals exchange data in both directions.

Lab: Synchronous Serial

I picked the APDS-9960 which is the color & gesture sensor. By connecting it to the Arduino through I2C port, it prints out values for red, green, blue, and clear channels. I also added a LED for lighting the object.


Some tests of color sensing. It’s pretty precise when it is close to the object. it may acts differently on different textures, for instance, the yellow one seems a little bit lighter than the real object.


Project 2 progress

Some progress about my accessible vibrating glove.

Make the vibration motor work

The vibration motor takes about 68~110mA to work which the Arduino pinout can’t support. So I need to add a transistor for each of them. I am considering to replace them with one ULN2003 chip (Darlington Array) since I need at least five motor. The test turned out pretty good, and I can control the magnitude of the vibration by PWM output.

Vibration Motor vibrating

For breadboard prototyping, I simply sticked the vibration motor to the board which didn’t work at all. Since the breadboard was solid and hard, it felt exactly the same when either of the motors vibrated. The solution was to add a soft layer between the motor and the board.


Sending more than one byte from p5 to Arduino

I got the solution here which is send and receive the bytes one by one until ‘\n’ is detected. I am sending the data by binary since the vibration value range from 0 to 255.

// P5
// Arduino
int vibration[2] = {0, 0};

void loop() {
  int index = 0;
  while (Serial.available() > 0) {
    int inByte = Serial.read();
    if (inByte == '\n') break;
    vibration[index] = inByte;

The game

The mechanics is very simple, balance the board and prevent the ball from falling. The bottom two red cicle are showing the vibration magnitude of each side. The more dangerous the situation, the stronger the vibration.

Arduino Code & P5 Code