Pages: [1]   Go Down
Author Topic: Modify code for laser harp  (Read 499 times)
0 Members and 1 Guest are viewing this topic.
Indonesia
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?


« Last Edit: March 24, 2013, 09:13:17 pm by juanda » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 650
Posts: 50838
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how to change the code for laser harp with 5 strings?
Most people use a text editor.
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4398
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Pages: [1]   Go Up
Jump to: