giovanni_canone
Published © GPL3+

Laser Harp

This is a musical instrument that uses MIDI communication, lasers, and photoresistors to generate sounds.

IntermediateWork in progress3,058
Laser Harp

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Photo resistor
Photo resistor
×1
Laser Diode, Visible
Laser Diode, Visible
×1
Audio / Video Cable Assembly, MIDI
Audio / Video Cable Assembly, MIDI
×1
DIN Audio / Video Connector, 5 Contacts
DIN Audio / Video Connector, 5 Contacts
×1
Sound card
×1

Software apps and online services

Apple Garage Band

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Laser Harp full schematic

Powers the laser modules.
Make a resistive divider with the photoresistors and 1KΩ resistors and connect them to the analog pins of Arduino.
Connect the midi port on the Arduino TX pin with a 220Ω resistor to protect the sound card (VERY IMPORTANT).

MIDI to Arduino connection

LDR circuit

Code

Laser Harp CODE

Arduino
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();

//Photoresistor connection pin
int LDR1 = A0;
int LDR2 = A1;
int LDR3 = A2;
int LDR4 = A3;
int LDR5 = A4;

//Tone selection
int NOTA1 = 72;
int NOTA2 = 74;
int NOTA3 = 76;
int NOTA4 = 79;
int NOTA5 = 81;

void setup() {
  Serial.begin(9600);
  
  MIDI.begin(MIDI_CHANNEL_OFF);
    
  pinMode(LDR1, INPUT);
  pinMode(LDR2, INPUT);
  pinMode(LDR3, INPUT);
  pinMode(LDR4, INPUT);
  pinMode(LDR5, INPUT);
}

void loop() {
  int SLDR1 = analogRead(LDR1);
  int SLDR2 = analogRead(LDR2);
  int SLDR3 = analogRead(LDR3);
  int SLDR4 = analogRead(LDR4);
  int SLDR5 = analogRead(LDR5);


   if (SLDR1 <= 400){//if the photoresistor detects less light it plays a note
    MIDI.sendNoteOn(NOTA1,120,1);
   }
   else{//if the photoresistor detects more light it stops the note
    MIDI.sendNoteOff(NOTA1,0,1);
   }

   if (SLDR2 <= 400){
    MIDI.sendNoteOn(NOTA2,120,1);
   }
   else{
    MIDI.sendNoteOff(NOTA2,0,1);
   }
      if (SLDR3 <= 400){
    MIDI.sendNoteOn(NOTA3,120,1);
   }
   else{
    MIDI.sendNoteOff(NOTA3,0,1);
   }

   if (SLDR4 <= 400){
    MIDI.sendNoteOn(NOTA4,120,1);
   }
   else{
    MIDI.sendNoteOff(NOTA4,0,1);
   }
      if (SLDR5 <= 400){
    MIDI.sendNoteOn(NOTA5,120,1);
   }
   else{
    MIDI.sendNoteOff(NOTA5,0,1);
   }
}

Credits

giovanni_canone

giovanni_canone

1 project • 1 follower

Comments