Lab 2 (The Elite Four)

The Elite Four (#24)
Clay Whetung (cwhetung@)
Jae Young Lee (jyltwo@)
Jeff Snyder (jasnyder@)
Michael Newman (menewman@)

What we built and why:
We built a softpot-based instrument that plays totally rocking guitar solos. It uses a softpot to select frequency and a button that allows sound to be played when pressed. We are collectively fans of not just one specific band, but rather the whole genre of rock ‘n’ roll. We wanted to make sure that all aspects of our instrument went up to 11, right across the board. Therefore, we modified our softpot-based prototype to use the most rocking of all pitch mappings: the blues scale. We were able to achieve a good approximation of many rock classics with our instrument, including “Tonight I’m Gonna Rock You Tonight” and “Stonehenge.” The thing we liked most about the final iteration was its ability to play sick guitar solos as well as classic riffs. Pitch was a little difficult to control precisely with a finger, as we needed a range of two octaves to really rock out, but it was easy to control with precision using a pencil or other stylus-like object. In a future iteration, the ability to play multiple notes at once would help us to rock out even harder. Specifically, the ability to play power chords would help us cement our status as one of F114’s loudest lab groups.

Prototypes:

Prototype 1

Jeff demonstrates our first prototype, a softpot-based instrument.

Jeff demonstrates our first prototype, a softpot-based instrument.

This prototype features a softpot that controls frequency (broken up into discrete notes) and a button that, when clicked, plays a note. By moving a finger along the softpot and simultaneously pressing the button, it’s possible to play simple melodies.

Prototype 2

By flexing his finger, Clay can change the frequency of this instrument.

By flexing his finger, Clay can change the frequency of this instrument.

This prototype features a flex sensor that controls frequency and a button that, when clicked, plays a note. We attached the flex sensor to our subject’s finger so that he was able to play different melodies simply by bending his finger while pressing the button.

Prototype 3

In this prototype, frequency is controlled by a force sensor, and clicking a button allows a note to be played. One can play a tune by squeezing the force sensor with varying degrees of force while simultaneously pressing the button.

The final system:
For the final system, we chose to work with our first prototype: the softpot-based instrument. As before, the button controls when a note is being played, but the mapping of softpot to frequency was altered to allow playing “guitar solos.” Below, we have photos and video of the system in action.

The entire system

The entire system

The final system's Arduino connections

The final system’s Arduino connections

Closeup of the breadboard, with button and speaker

Closeup of the breadboard, with button and speaker

finalphoto5

Closeup of the frequency-controlling softpot

As seen in the video, the system has been refined to allow rockin’ riffs instead of just simple melodies. This change was made by altering the system’s code, not by changing the hardware.

Ingredients:
1 Softpot
1 Speaker
1 Large Button
1 Arduino
Breadboard(s)
Jumper Wires
Tape

Recipe:
0. Insert the softpot, speaker, and button into the breadboard. The speaker and button are most easily inserted spanning the middle divider. You may find it helpful for the following steps to connect ground and +5V to the power rails of the breadboard.
1. Attach the far left pin of the softpot to ground and the far right to +5V. Connect the middle pin to the A0 pin of the Arduino.
2. Connect one side of the speaker to ground and the other to one side of the button. Connect the other side of the button to pin 8 of the Arduino.
3. For added stability, tape the softpot to a hard surface (like the table).

Source code:

/* 
  Authors: jasnyder, cwhetung, menewman, jyltwo
  Date: 3/4/2013
  COS 436 Lab L2: Awesome Electric Guitar Instrument

  Our instrument: By using a softpot, we created something similar
  to a keyboard. We first experimented with a typical scale, and eventually
  chose notes to make a solo electric guitar. There are 10 possible pitches
  mapped by the softpot, and the sound is outputted through the speaker as
  values are continously read in. 
*/

#include "pitches.h"

// Pitches on our guitar
int pitches[] = {NOTE_G5, NOTE_AS5, NOTE_C6, NOTE_DS6, NOTE_F6, 
                 NOTE_FS6, NOTE_G6, NOTE_AS6, NOTE_C7, NOTE_DS7};

//  Musical constants
const int NOTE_DELAY = 300; // ms
const int NOTE_DUR = 250;   // ms

//  Pin connection constants
const int softpot = A1;
const int speaker = 8;

// Softpot reading
int softpotValue = 0;
// Mapped value of softpot
int note = 0;

// Continuously read values from the softpot and output the corresponding tone
void loop() {
  softpotValue = analogRead(softpot);
  note = map(softpotValue, 0, 1023, 0, 9);

  tone(speaker, pitches[note], 1);
}