Project showcase
Musical Cube

Musical Cube © LGPL

This project started from FabLab of Boilchon High School. Turning the button changes the sound.

  • 1,479 views
  • 0 comments
  • 1 respect

Components and supplies

Necessary tools and machines

Lasercutter
Laser cutter (generic)

Apps and online services

About this project

Our teacher made us to make something. So, we thought and made this.

This cube is an instrument. This cube makes various sounds, when we turn the potentiometer.

Code

Untitled fileArduino
int Pot = A1;
int av;
int Switch = 5;
int SwitchState = 0;
int L7 = 6;
int L8 = 3;
int L9 = 2;
int L10 = 9;
int speaker = 8; // Breadboard 2
void setup() {
  Serial.begin(9600);
  pinMode (speaker, OUTPUT);
  pinMode (Switch, INPUT);
}
void loop() {
  av = analogRead(Pot);
  av = map(av, 0, 1023, 1, 5);
  Serial.print(av);
  Serial.println(SwitchState); 
  SwitchState = digitalRead(Switch);
   if(av == 1){
    digitalWrite(L7, HIGH);
    digitalWrite(L8, LOW);
    digitalWrite(L9, LOW);
    digitalWrite(L10, LOW);
  }else if(av == 2){
    digitalWrite(L7, LOW);
    digitalWrite(L8, HIGH);
    digitalWrite(L9, LOW);
    digitalWrite(L10, LOW);
  }
  else if(av == 3){
    digitalWrite(L7, LOW);
    digitalWrite(L8, LOW);
    digitalWrite(L9, HIGH);
    digitalWrite(L10, LOW);
  }
  else if(av == 4){
    digitalWrite(L7, LOW);
    digitalWrite(L8, LOW);
    digitalWrite(L9, LOW);
    digitalWrite(L10, HIGH);
  }
if(SwitchState == 1){
  if(av == 1){
    tone(speaker, 2979, 10);
  }else if(av == 2){
    tone(speaker, 3363, 10);
  }else if(av == 3){
    tone(speaker, 3747, 10);
  }else if(av == 4){
    tone(speaker, 4003, 10);
  }
}
} 
Untitled fileArduino
int Pot = A1;
int av;
int Switch = 5;
int SwitchState = 0;
int L7 = 6;
int L8 = 3;
int L9 = 2;
int L10 = 9;
int speaker = 8; // Breadboard 2
void setup() {
  Serial.begin(9600);
  pinMode (speaker, OUTPUT);
  pinMode (Switch, INPUT);
}
void loop() {
  av = analogRead(Pot);
  av = map(av, 0, 1023, 1, 5);
  Serial.print(av);
  Serial.println(SwitchState); 
  SwitchState = digitalRead(Switch);
   if(av == 1){
    digitalWrite(L7, HIGH);
    digitalWrite(L8, LOW);
    digitalWrite(L9, LOW);
    digitalWrite(L10, LOW);
  }else if(av == 2){
    digitalWrite(L7, LOW);
    digitalWrite(L8, HIGH);
    digitalWrite(L9, LOW);
    digitalWrite(L10, LOW);
  }
  else if(av == 3){
    digitalWrite(L7, LOW);
    digitalWrite(L8, LOW);
    digitalWrite(L9, HIGH);
    digitalWrite(L10, LOW);
  }
  else if(av == 4){
    digitalWrite(L7, LOW);
    digitalWrite(L8, LOW);
    digitalWrite(L9, LOW);
    digitalWrite(L10, HIGH);
  }
if(SwitchState == 1){
  if(av == 1){
    tone(speaker, 2851, 10);
  }else if(av == 2){
    tone(speaker, 3235, 10);
  }else if(av == 3){
    tone(speaker, 3491, 10);
  }else if(av == 4){
    tone(speaker, 3747, 10);
  }
}
} 

Schematics

Musical Cube
It looks complicated but not difficult.
aaaa_1tkhooHgxT.fzz

Comments

Similar projects you might like

Musical Fairy Lights

Project tutorial by Ian Cumming

  • 4,841 views
  • 0 comments
  • 11 respects

Simple Programmable Robotic Arm

Project showcase by Ryan Chan

  • 49,171 views
  • 63 comments
  • 145 respects

Xmas musical robot

Project showcase by benoitdr

  • 729 views
  • 0 comments
  • 2 respects

LED CUBE 4x4x4

Project showcase by MakerRobotics

  • 23,974 views
  • 4 comments
  • 61 respects

LED Cube

Project tutorial by Praditha Alwis

  • 5,040 views
  • 0 comments
  • 12 respects

You've Been Using a Button Wrong this Whole Time

Project tutorial by SMM2

  • 2,731 views
  • 1 comment
  • 3 respects
Add projectSign up / Login