Tuesday, December 2, 2014

December 2nd Update

After all of our hard work, it seems that our final project is almost ready to be put into action. The group is very proud of the work that we put into the design project and of the pre-final result. The following is the code that our group decided upon using to create our paper piano.

#include <CapacitiveSensor.h>
#define speaker 11
CapacitiveSensor   cs_2_3 = CapacitiveSensor(2,3);       
CapacitiveSensor   cs_2_4 = CapacitiveSensor(2,4);       
CapacitiveSensor   cs_2_5 = CapacitiveSensor(2,5);       
CapacitiveSensor   cs_2_6 = CapacitiveSensor(2,6);      
CapacitiveSensor   cs_2_7 = CapacitiveSensor(2,7);       
CapacitiveSensor   cs_2_8 = CapacitiveSensor(2,8);       
CapacitiveSensor   cs_2_9 = CapacitiveSensor(2,9);     

void setup()                   
{
  cs_2_3.set_CS_AutocaL_Millis(0xFFFFFFFF);    
 
 
  Serial.begin(9600);
}
void loop()                   
{

  long start = millis();
 
 
  long total1 =  cs_2_3.capacitiveSensor(60);
  long total2 =  cs_2_4.capacitiveSensor(60);
  long total3 =  cs_2_5.capacitiveSensor(60);
  long total4 =  cs_2_6.capacitiveSensor(60);
  long total5 =  cs_2_7.capacitiveSensor(60);
  long total6 =  cs_2_8.capacitiveSensor(60);
  long total7 =  cs_2_9.capacitiveSensor(60);
 

  Serial.print(millis() - start);       
  Serial.print("\t");                   
  Serial.print(total1);                 
  Serial.print("\t");                   
  Serial.print(total2);                 
  Serial.print("\t");                  
  Serial.print(total3);                
  Serial.print("\t");                   
  Serial.print(total4);                 
  Serial.print("\t");                   
  Serial.print(total5);                 
  Serial.print("\t");                   
  Serial.print(total6);                 
  Serial.print("\t");                   
  Serial.println(total7);               
                                        
 
  if (total1 > 150) tone(speaker,523);
  if (total2 > 150) tone(speaker,587);
  if (total3 > 150) tone(speaker,659);
  if (total4 > 150) tone(speaker,698);
  if (total5 > 150) tone(speaker,784);
  if (total6 > 150) tone(speaker,880);
  if (total7 > 150) tone(speaker,988);
 
 
  if (total1<=150  &  total2<=150  &  total3<=150 & total4<=150  &  total5<=150  &  total6<=150 &  total7<=150)
    noTone(speaker);
  delay(0);                             
}


This final code will be used to hopefully make our design as seen in the photo below work as desired!




No comments:

Post a Comment