Nothing Like a Squeezebox

Project 1
with Phil Caridi & Anh Le

Based on what we learned for the past four weeks, we want to create something that incorporates components from previous Labs. Our project scope was to create a small DJ station with:

  • One rotary potentiometer
  • One ribbon/flex sensor that can be used to change the tone/pitch of the audio
  • One (or multiple) LEDs to indicate that the audio is on/off

Other ideas/functions we wanted to try exploring:

  • To map the range of the circular ribbon sensor to the RGB LED, so that the colours would change according to the touch sensor
  • To map the sound of the speaker to the musical notes, so different areas of the sensor will trigger different musical notes
  • To have multiple ribbon sensors

Process:

Since we are familiar with the setup of sensor + speaker combo, and adding LED should be fairly straightforward (we were wrong), we just need to work on incorporating the circular ribbon sensor into the circuit & the code component that comes with it. 

We started by setting up the circular ribbon sensor and mapped its values and ranges. The ribbon sensor produced minimal but noticeable changes when touched, but the overall sound was not audible. Both Phil and I had pretty small speaker output from Lab 3, so it’s crucial that we figured out how to amplify it. We followed the transistor’s tutorial, as demonstrated by Tom, tried connecting it to Arduino Uno and changed to 5.5V, also found several other examples online, etc. but none of them seemed to work. 

We decided it’s best to work on small chunks of circuits at a time, to ensure they are working and functioning as intended, before integrating them it into one big circuit setup, so: 1. connect ribbon sensor & rotary potentiometer to the speaker 2. connect speaker & pot to transistor 3. connect LED to the pots & speaker 4. integrate/code all components together.

Documentation:

1. Speaker + Rotary Pot with working Ribbon Sensor but small sound ft. Saturday Applications class

2. Speaker with Transistor for some audibly LOUD SOUND. Breadboard was tight so have to press the Arduino down.

3. Speaker + Potentiometer + Ribbon Sensor. Sound is clear, but there was not much difference in sound when rotating the pot vs pressing on the sensor.

4. Played around with the delay(). Found the pitch and range that we want to keep. We wanted to make sure that there is a clear, audible differentiation between the rotary pot and the ribbon sensor.

5. Testing RGB LED with ribbon sensor and rotary pot, LED is flickering but is not entirely responsive to either pots.

6. Cue the RGB LED drama. Played with more delay() settings while trying to connect the LED to the pot. Still no relationship/correlation between pot and LED, the latter is flickering randomly.

  • We spent a good chunk of time trying to incorporate RGB LEDs and got into an interesting situation where everything seems to be working in reverse. We noticed that the LEDs display the opposite colour of what we input (i.e. red (255,0,0) would trigger blue/cyan, and cyan(0,255,255) would trigger red). We changed the digital input pin, flipped the LED, checked the datasheet, added and blocked out multiple code lines, but nothing seemed to work.
  • We decided to test again with a different RGB LED found on the floor, and it worked! That’s when we realised that we have been working with anode RGB LED all along, using a code written for a cathode RGB LEDs. We also noticed how the anode connects to negative/ground, while cathode connected to positive/red. Why are there two different kinds, and what are some of the occasions or purposes where having two different types of LEDs would be beneficial?

7. Final Output: We discovered the RGB LED mystery (described below), dropped it and decided to use two LEDs instead. Each pot controls one LED.

Schematic:

Arduino code:

const int blueLed = 8;
const int redLed = 7;
int analogValue1 = 0;
int brightness1 = 0;
int analogValue2 = 0;
int brightness2 = 0;

void loop() {
// get sensor reading
int rotPot = analogRead(A0);
int ribPot = analogRead(A1);

//map results of sensor range to pitch range
float frequency = map(rotPot, 0, 1023, 50, 880);
float pitch = map(ribPot, 0, 255, 440, 880);
// float blueLed = map(brightness1, 0, 1023, 0, 255);
// float redLed = map(brightness2, 0, 1023, 0, 255);

analogValue1 = analogRead(A0);
brightness1 = analogValue1 / 4;
analogWrite(blueLed, brightness1);

analogValue2 = analogRead(A1);
brightness2 = analogValue2 / 4;
analogWrite(redLed, brightness2);

tone(9, frequency);
delay(10);
tone(9, pitch, 100);
delay(10);

int analogOne = analogRead(A0);
delay(10);
int analogTwo = analogRead(A1);
delay(10);

Serial.println(analogOne);
Serial.println('\t');
Serial.println(analogTwo);
Serial.println('\t');
Serial.println(brightness1);
Serial.println('\t');
Serial.println(brightness2);
}

The output is different from what we planned, but still cool nonetheless! The DJ Station is on and will play the sound by default. We have two modes of controlling the audio, and both produce noticeable differences/alterations to the audio. We also have two corresponding coloured LEDs light that will flicker (when the user touch the ribbon sensor) or turn on and off (when the user turn the rotary potentiometer). Phil also made awesome renderings and prototype the enclosure of what it can look like!

Renderings and prototype of enclosure:

Takeaway:

  • We recreated the circuit setup many times to debug, and this was where working on multiple breadboards really helped. One of our ongoing challenges was to connect the pots/speaker setup to the LEDs. We transferred the LEDs setup through multiple breadboards to debug, and each time we always seemed to miss out on something (wrong digital or analog pin, wrong leg, wrong connection to power/ground, forgot to bridge across the breadboard, forgot to change digital pin number in the code, etc.) Overall, this project helped us to be proactive in troubleshooting and to try as many solutions or approaches as we can because at this stage, there are only so many things that can go wrong (…right?)
  • Color-coding is important, so are documentation and iterations, very important to keep a note so we have something to fall back on in case future experimentations failed.

Questions:

  • Difference between Cathode and anode LED, and why is there a need for both? What are some use cases for these two types of LEDs?
  • How to map the sensor to the music notes and/or LED? We tried this earl
  • How to map the output of the sensor to the LED while something else is being used/mapped? 
  • How to use analog input to control two outputs?
  • We were playing around with digital inputs, with most of our current setups using digital pin 7 to 9. We switched to digital pin 5 & 6 once and that, when combined with our (semi) working code, shut down the board. Why did that happen?
  • We layered some delays() and they produced interesting audio effects?