Final Project – Invisible Instrument, Night Light?

For my project I was continuing what I did for project 2 playing with midi, serial, and Arduino.

This project took me a while to figure out, since I don’t have the strongest foundation in code I would like!

I kept playing around with my code from project 2 to see if I could try to trigger other things besides pitch and noteON and noteOFF.
For my project I wanted to use multiple sensors to control different parts of a MIDI instrument, for example: pitch, cutoff, velocity etc.

I talked with name and she told me to just start with testing each of the sensors I was going to use before putting them together.

I find some code from different websites where people had done some thing similar to what I wanted to achieve. The best code example I found was from this website:

I then combined it with the code from this website: that just has a bunch of demos on sensors and midi. I used this website to understand how to code and map the sensor values to things like pitch and velocity.

I first started with just making sure that my photocell was working since I suavely have problems with it:

int photocellPin = 0; // the cell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from the sensor divider
int LEDpin = 11; // connect Red LED to pin 11 (PWM pin)
int LEDbrightness; //
void setup(void) {
// We’ll send debugging information via the Serial monitor

void loop(void) {
photocellReading = analogRead(photocellPin);

Serial.print(“Analog reading = “);
Serial.println(photocellReading); // the raw analog reading

// LED gets brighter the darker it is at the sensor
// that means we have to -invert- the reading from 0-1023 back to 1023-0
photocellReading = 1023 – photocellReading;
//now we have to map 0-1023 to 0-255 since thats the range analogWrite uses
LEDbrightness = map(photocellReading, 0, 1023, 0, 255);
analogWrite(LEDpin, LEDbrightness);


When I first did the lab I couldn’t get my LSR to work, turns out my pull down switch wasn’t wired correctly. ¯\_(ツ)_/¯ At first that it was the resistor that was problem since the values I got were weird. I sent my circuit and code to Name and she pointed out the problem. (a life saver truly)


Next, I tested the potentiometer with Arduino. The Arduino triggered sound and the potentiometer controlled pitch.

After that, I put together the code for the potentiometer and the light. I got something like this:

I didn’t really like how it was running in Ableton, it didn’t really feel like the LSR was doing much. I also noticed that the lights weren’t working at first. I took a step back and just used the LSR and potentiometer to make sure I didn’t have an error in my code or circuit.


My notes: WORKS WELL VERY CLEAN.  light sensor controls pitch, and potentiometer controls velocity its almost like a dance trying to get certain notes to play, It be cool to have too of these objects and than do like a dance performance / “music” performance with these…“Invisible instruments” Or “light instruments” 

byte noteON = 144;

int analogPin = A0; // lsr 

int potPin = A1; // potentiometer

void setup() { 



void loop(){ 

int analogValue = analogRead(analogPin);

byte note = map(analogValue, 0, 1024, 0, 127);

int potVal  = analogRead(potPin); // read data from potentiometer

byte velocity = map(potVal, 0, 1023, 0, 127); 

MIDImessage(noteON, note, velocity); 


MIDImessage(noteON, note, 0); 



void MIDImessage(byte command, byte data1, byte data2) {






What would I change?

I think if I had more time for this project I would make the object holding the writing a lot cleaner. For example, I would sauter the pieces to the board. I’d also sauter the wire to gather for the sensors and the LED lights. Currently the LED’s are outside of the ʕ·ᴥ·ʔ bear since the connection is pretty sensitive. I would love to have the LED’s in the bears cheeks. I think it be nice to maybe use a neopixel that could light up and pulse with the amount of light being received by the photo cells.

using some more soothing sounds as suggested in class


  • Midi kept triggering more notes than the ones assigned
  • couldn’t figure out how to code cutoff
  • wiring on circuit is super sensitive
  • ran into some errors when coding, usually due to note defining something or forgetting “}” or “;”
  • even after talking to Yeseul the midi was still triggering extra notes???
  • not as fluid as I would have liked but still fun

I Learned

  • I definitely feel more comfortable in coding than before
  • about how MIDI works within computers for software
  • Mistakes will be made!
  • Patience
  • I like the really harsh sounds ~ something like this could be cool for noise music.

Leave a Reply

Your email address will not be published. Required fields are marked *