Go Down

Topic: Modify code for laser harp (Read 540 times) previous topic - next topic

juanda

Mar 25, 2013, 03:00 am Last Edit: Mar 25, 2013, 03:13 am by juanda Reason: 1
I have a code for laser harp with one string, like this :

Quote
#define MIDICMD_NOTEON 0x90 // MIDI command (Note On, Channel 0)
int sensorPin = 2;    // select the input pin for the LDR
int ledPin = 13;   // select the control pin for the LED
int val = 0;       // variable to store the value coming from the sensor
int potPin = 0;    // select the input pin for the potentiometer
int note = 0;


void SendMIDI(char cmd, char data1, char data2)
{
 Serial.print(cmd);
 Serial.print(data1);
 Serial.print(data2);
}

void setup()
{
 // Set MIDI baud rate:
 Serial.begin(31250);
 //Serial.begin(14400);
 pinMode(ledPin, OUTPUT) ;
}

void loop() {
 

 note = analogRead(potPin);    // read the value from the sensor
 val = map(val, 0, 1023, 0, 100);
 
int val = analogRead(sensorPin);
if (val <= 950){  

   SendMIDI(MIDICMD_NOTEON, note, 127);      // NOTE_ON
   digitalWrite(ledPin, LOW);  // turn the led off  
     delay(5);
   while(val > 600) {val = analogRead(sensorPin);}  
}
else    {

   SendMIDI(MIDICMD_NOTEON, 60, 0);     // NOTE OFF
   digitalWrite(ledPin, HIGH);   // turn the led on
   delay(350);

}
}


how to change the code for laser harp with 5 strings?



http://www.youtube.com/watch?v=nRoZbkAJsB8

PaulS

Quote
how to change the code for laser harp with 5 strings?

Most people use a text editor.

UKHeliBob

I am not a fortune teller but I foresee the use of arrays in your near future and the removal of delay() from your code to keep it responsive.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up