Bit Bit Dance

For Physical Computing’s midterm project, I created Bit Bit Dance with my teammate Paul Hiem. Bit Bit Dance is a dance battle game controlled by custom made shoe sole sensors. Taking 8 bit music and graphics, we created a dancing character for each of the two players. When the player dances, the character also dances and 8 bit bitcoins falls into the character’s hat. When the time is up, the amount of bitcoins collected by each player is counted and displayed. 

Check out Project Fanny Pack: Making the Bit Bit Dance Controller here.

dance_s

controller_2

A player’s feet controls six different interactions:

  • Left heel up, left heel down, right heel up, right heel down each controls one of the character’s movement and each creates a different sound effect
  • Right heel pressed for a sustained period of time starts the background music and starts the timer
  • Left heel pressed for a sustained periord of time pauses the background music

Two LEDs attached the controller signals which foot is down or pressed, providing direct feedback to the player or observer.

set

Controller includes: enclosed microcontroller (Arduino) and circuitry, shoe sole sensors, and wires.

The casing for the microcrontroller is designed with an adjustable strap that can loop around a belt.

The casing is designed with an adjustable strap that can loop around a belt.

software

Bit Bit Dance software.

Bit Bit Dance software.


Lab 4: Two-way serial communication

When reading multiple sensors a question that comes up is “which value corresponds with which sensor?” There are two ways to set sensor values in order: punctuation method, which involves punctuating each set of data uniquely, and call-and-response (handshake) method, which works very much like it sounds, sending one set of values at a time by setting the programs to call and respond to each other.

We tried each method in this lab, neither worked very well for me. And I have a lot of questions regarding the additional code.

This is what I’ve learned so far:

Punctuation method

To send data from the Arduino, we use Serial.print() and Serial.println() to send out each set of values, separated by commas Serial.print(“,”);.

To receive the values in Processing, we add myPort.bufferUntil(‘\n’); in setup() so that the string of values would be saved to the buffer and read together. In the serialEvent() function, the string is read with myPort.readStringUntil(‘\n’);. Then trim out any whitespace character (newline, carriage returns, spaces, tabs) with trim(stringx), split the values at each comma with split(stringx, ‘,’);, convert the values into integers and store them in an array, for instance int sensor[] = int(split(stringx, ‘,’));.

There are a few downsides to this method, namely the program may slow down if the buffer is full and that we can’t easily send binary values.

Call-and-response method

In the Arduino IDE, we setup a new function establishContact(). This function sends out a message until receives data from Processing. We check for data by checking whether Serial.available() is greater than 0 (true) or less then/equal to 0 (false). We call for this new function in setup(). Then, with an if statement, make sure that the strings of values in loop() would only send when Serial.available() is greater than 0.

In Processing, we check for contact with a new variable boolean firstContact = false;. In serialEvent() we let the program first check if the message from the Arduino is the right one with myString.equals(), then send back a character with myPort.write() to start receiving actual data. If firstContact is true, the code from the rest of serialEvent() would run, trimming, splitting, converting, and storing the values.

Issues: 

  • With the lab (make a simple DIY mouse), my digital input worked well, allowing the ball to appear and disappear from the screen. But with the ball fluttered about when I moved the accelerometer. Instead of moving on the x and y axis smoothly, the ball was all over the place.
  • Often the program didn’t even run. It displayed an error message.
Error message in Processing.

Error message in Processing.

Questions:

  • Why is the call-and-response method better for sending binary data, even though it’s also sending and receiving strings with commas, then trimming, splitting, and storing them in a buffer? Also, wouldn’t this also slow down the program if the buffer gets full?
  • Why do we need to call-and-respond between the programs?
  • Explain more about the new functions in Arduino IDE and Processing. e.g. Serial.available(), trim(), split(), myPort.bufferUntil(), myPort.readStringUntil(), myString.equals(), etc.
Values show up properly in the Arduino IDE serial monitor.

Values show up properly in the Arduino IDE serial monitor.

Digital input works. Issues with analog input values.

Digital input works. Issues with analog input values.

Lab 4: Serial Communication

This week in P Comp, we are learning about serial communication. Serial communication is a way to allow computers to talk to each other. This is very exciting because we can now start to create projects where physical interfaces interact with interfaces on the screen and we can start to think about how a network of connected physical objects can be controlled through one computer. At the same time there are a lot of materials covered this week and after going over the videos and labs I’m filled with questions.

What I’ve learned so far:

Serial communication works by sending a series of digital pulses back and forth between devices. In order for these two devices to communicate they need to agree on three things: the rate at which data is sent and read, the voltage levels that would represent 1 and 0 bits, and the meaning of the voltage levels (does 1 mean high and 0 mean low or reversed). Serial communication protocol defines the structure of communication. It’s kind of similar to facilitating a conversation between two people.

The Arduino uses a USB-to-serial converter so that the USB connection would show up as serial port on the computer. The serial port can only be controlled by one program at a time. So if I have the serial monitor open in the Arduino IDE, I need to close it to run my Processing sketch that also use the serial port. Aside from Processing, any other environment (?) that can access the serial port can also be used to communicate with the Arduino. The physical connection happens through three lines: the transmit (Tx) to receive (Rx) line, the Rx to Tx line, and the ground line.

IMG_3556

There is an area in the processor’s memory where incoming data from the serial port is stored. This is the serial buffer. I used this in the lab to smooth out signals from Arduino IDE (?) by storing data in to strings and sending them only after the end of a line.

Issues:

  • The graph from the Serial to Processing lab looked quite different for mine. I’m not sure whether it’s because I used a different sensor. The graph had started looking smoother (with each line touching) but after I changed something in the code a gap showed up between each line.

Questions:

  • Other devices connecting with the Arduino vs. connecting directly with a computer. What are some examples of application for both methods?
  • Explain more about serial buffer.
  • Why can only send 1 byte with Serial.write() but Serial.println() can send more than 1 byte?
  • Explain more about the difference between RS-232 and USB.
The ball didn't respond the first time I tried, because I had called Serial.println() instead of Serial.write().

The ball didn’t respond the first time I tried, because I had called Serial.println() instead of Serial.write().

Different formats (HEX, binary, ASCII) of the same data can be read through CoolTerm.

Different formats (HEX, binary, ASCII) of the same data can be read through CoolTerm.

There is a gap between each line, instead of producing a smooth graph.

There is a gap between each line, instead of producing a smooth graph.