Synesthetic Pitch Sensor

Description

Synesthesia is a neurological condition in which stimulation of one sensory/cognitive pathway leads to an involuntary experience in a secondary sensory/cognitive pathway. The Synesthetic pitch sensor was created  to serve as a model for this concept, specifically color synesthesia relative to sound. A photocell is employed as an analog input to control the pitch from the output piezo speaker. RGB LEDs are then utilized to illustrate a certain color corresponding with what pitch is heard by the user. 

 

Materials

3 RGB LEDs

1 Piezo speaker

1 photocell

Plastic Sheets

Styrofoam for LED diffuser 

 

Arduino Code

 

/*
Color synesthesia pitch model
by Andrea Hsieh
created 4 Oct 2011
 
modification of 
Pitch Follower 
 created 21 Jan 2010
 Modified 4 Sep 2010
 by Tom Igoe
 
This example code is in the public domain.
 http://arduino.cc/en/Tutorial/Tone2
 
 */
 
 //Analog pin setting
int sensorPin = A0;
 
//Digital pin settings
int greenPin = 10;
int redPin = 11;
int bluePin = 12;
int speakerPin = 9;
 
//Values
int val = 0;
 
void setup() {
  // initialize serial communications (for debugging only):
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode (bluePin, OUTPUT);
  pinMode (speakerPin, OUTPUT);
  Serial.begin(9600);
  analogWrite(greenPin, 0);
  analogWrite(redPin, 0);
  analogWrite(bluePin, 0);
  
}
 
void loop() {
  // read the sensor:
  int sensorReading = analogRead(A0);
  // print the sensor reading so you know its range
  Serial.println(sensorReading);
  // map the pitch to the range of the analog input.
  // change the minimum and maximum input numbers below
  // depending on the range your sensor's giving:
  int thisPitch = map(sensorReading, 50, 400, 400, 50);
 
  // play the pitch:
  tone(9, thisPitch, 10);
  
  // show color
  val = analogRead(sensorPin); //read value from sensor
  
  if(val > 350){
    analogWrite(greenPin,255);
    analogWrite(redPin,255);
    analogWrite(bluePin,255);
    //all
  }
  if(val <= 350){
    analogWrite(greenPin, 255);
    analogWrite(redPin, 0);
    analogWrite(bluePin, 255);
    //cyan
  }
  if(val <= 300){
    analogWrite(greenPin, 127);
    analogWrite(redPin, 0);
    analogWrite(bluePin, 255);
  }
  if(val <= 250){
    analogWrite(greenPin, 0);
    analogWrite(redPin, 0);
    analogWrite(bluePin, 255);
    //blue
  }
  if(val <= 200){
    analogWrite(greenPin, 0);
    analogWrite(redPin, 127);
    analogWrite(bluePin, 255);
    //purple
  }
  if(val <= 150){
    analogWrite(greenPin, 0);
    analogWrite(redPin, 255);
    analogWrite(bluePin, 255);
  }
  if(val <= 100){
    analogWrite(greenPin, 0);
    analogWrite(redPin, 255);
    analogWrite(bluePin, 127);
  }
  
  if(val <= 75){
    analogWrite(greenPin, 0);
    analogWrite(redPin, 255);
    analogWrite(bluePin, 0);
  }
  
 
}
 
 
 
 
 

 

content___media_external_images_media_45_0.jpg
0
Your rating: None