Go Down

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


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 :

#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)

void setup()
 // Set MIDI baud rate:
 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  
   while(val > 600) {val = analogRead(sensorPin);}  
else    {

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


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



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

Most people use a text editor.
The art of getting good answers lies in asking good questions.


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