Funky Music Maker

After watching the videos on changes and developments in music in class, I got to thinking about what would be a cool, funky way to make music with electronics. I decided that a fun experimental music making idea would combine the ability to change the type of sound quickly on a speaker (frequency) as well as add in the taps that could go with a beat based on your leg moving up and down. This being triggered by your leg would leave a hand open to change out what is being tapped by the solenoid and thus change the sound heard from it. As someone who knows nothing about music and notes, I chose for someone to just change the frequency so that there would be no barriers from someone trying it out. For this proof of concept, I chose to have the speaker turn off when the IR beam is broken and the solenoid moves as it overpowers the sound otherwise.

int solenoidPin = 9;
const int IRpin = 3;
int IRstate;
int potPin = A0;
int potVal;
int speakerPin = 13;
int frequency;

void setup()
  pinMode(solenoidPin, OUTPUT);
  pinMode(IRpin, INPUT);
  digitalWrite(IRpin, HIGH);
  pinMode(potPin, INPUT);
  pinMode(speakerPin, OUTPUT);

void loop()
  potVal = analogRead(potPin);
  frequency = map(potVal, 0, 1023, 1, 1000);
  IRstate = digitalRead(IRpin);
  static int start = millis();
  digitalWrite(solenoidPin, !IRstate);
  if (IRstate == 1) {
    tone(speakerPin, frequency);
  else { //broken



Hey everyone! I'm a senior in mechanical engineering with a minor in physical computing. I'm looking forward to getting to know all of you and build some cool projects:)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.