Project showcase
Musical Cube

Musical Cube © LGPL

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

  • 2,491 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

  • 6,757 views
  • 0 comments
  • 13 respects

Simple Programmable Robotic Arm

Project showcase by Ryan Chan

  • 99,594 views
  • 94 comments
  • 256 respects

Xmas musical robot

Project showcase by benoitdr

  • 1,090 views
  • 0 comments
  • 4 respects

LED CUBE 4x4x4

Project showcase by MakerRobotics

  • 43,340 views
  • 8 comments
  • 80 respects

LED Cube

Project tutorial by Praditha Alwis

  • 11,391 views
  • 0 comments
  • 18 respects

You've Been Using a Button Wrong this Whole Time

Project tutorial by SMM2

  • 9,643 views
  • 1 comment
  • 6 respects
Add projectSign up / Login