| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

KarimRowel_FinalProject

Page history last edited by Karim 10 years, 7 months ago

Design point of view

 

     I initially got my idea for my final project when i saw Benjamin Williams working on his spy gear. Whenever he pressed the self destruct button LEDs would light up and a sound would play. It was in that moment that I thought of making an 8 bit piano. I realized that this would be a great project for DJ's to experiment with possible electronic sounds. especially because if you press more than one button at a time the Arduino micro interprets it in a way that makes the sound seem distorted (something modern DJs particularly like). 

     People always talk about why encapsulation is so good, however, one of the reasons that encapsulation is bad is that the user has no idea what is going on inside their devises. I decided to leave the top of my device open so that the user could fully appreciate what they were using and easily make any modifications.

 

Verplank diagram

 

 

Paper prototype

 

 

Just a box with 8 keys. I was really shooting for simplicity.

 

Actual prototype

 

 

State diagram

 

 

Project code

 

/*

 8 - bit Piano

 Plays a different note for each pressed button and plays a distorted sound 

 i two or more buttons are pressed at the same time.

 

 circuit:

 * 8-ohm speaker on digital pin 8

 

 Parts of this example code is in the public domain.

 

 http://arduino.cc/en/Tutorial/Tone

 

 */

 

#include "pitches.h"

 

int melody[] = {

  NOTE_D3,NOTE_D3,NOTE_D3,NOTE_G3,NOTE_D4,NOTE_C4,NOTE_B3,NOTE_A3,NOTE_G4,NOTE_D4, \

  NOTE_C4,NOTE_B3,NOTE_A3,NOTE_G4,NOTE_D4,NOTE_C4,NOTE_B3,NOTE_C4,NOTE_A3,0};

 

int noteDurations[] = {

  10,10,10,2,2,10,10,10,2,4, \

  10,10,10,2,4,10,10,10,2,4};

 

 

// constants won't change. They're used here to 

// set pin numbers:

const int buttonPin1 = 9;     

const int buttonPin2 = 7; 

const int buttonPin3 = 6;

const int buttonPin4 = 5;

const int buttonPin5= 4;     

const int buttonPin6 = 3; 

const int buttonPin7 = 2;

const int buttonPin8 = 10;

 

 

// variables will change:

int buttonState1 = 0;         

int buttonState2 = 0;

int buttonState3 = 0;

int buttonState4 = 0;

int buttonState5 = 0;         

int buttonState6 = 0;

int buttonState7 = 0;

int buttonState8 = 0;

 

 

 

void setup() {

  // iterate over the notes of the melody:

  for (int thisNote = 0; thisNote < 20; thisNote++) {

 

    // to calculate the note duration, take one second 

    // divided by the note type.

    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.

    int noteDuration = 1000/noteDurations[thisNote];

    tone(8, melody[thisNote],noteDuration);

 

    // to distinguish the notes, set a minimum time between them.

    // the note's duration + 30% seems to work well:

    int pauseBetweenNotes = noteDuration * 1.30;

    delay(pauseBetweenNotes);

    // stop the tone playing:

    noTone(8);

  }

 

  // initialize the LED pin as an output:

 

 

  // initialize the pushbutton pin as an input:

  pinMode(buttonPin1, INPUT);  

  pinMode(buttonPin2, INPUT);  

  pinMode(buttonPin3, INPUT);

  pinMode(buttonPin4, INPUT);

  pinMode(buttonPin5, INPUT);  

  pinMode(buttonPin6, INPUT);  

  pinMode(buttonPin7, INPUT);

  pinMode(buttonPin8, INPUT);

 

}

 

void loop() {

  // read the state of the pushbutton value:

  buttonState1 = digitalRead(buttonPin1);

  buttonState2 = digitalRead(buttonPin2);

  buttonState3 = digitalRead(buttonPin3);

  buttonState4 = digitalRead(buttonPin4);

  buttonState5 = digitalRead(buttonPin5);

  buttonState6 = digitalRead(buttonPin6);

  buttonState7 = digitalRead(buttonPin7);

  buttonState8 = digitalRead(buttonPin8);

 

  // check if the pushbutton is pressed.

  // if it is, the buttonState is HIGH:

  if (buttonState1 == HIGH) {     

    // turn LED on:    

 

    tone(8, NOTE_D4);

  } 

  else {

    // turn LED off: 

 

    noTone (8);

  }

  if (buttonState2 == HIGH) {     

    // turn LED on:    

 

    tone(8, NOTE_D3);

  } 

  else {

    // turn LED off:

    noTone (8);

  }

  if (buttonState3 == HIGH){

 

  tone (8, NOTE_F3); 

  }

  else {

 

    noTone (8);

  }

   if (buttonState4 == HIGH) {     

    // turn LED on:    

 

    tone(8, NOTE_G3);

  } 

  else {

 

    noTone (8);

  }

  if (buttonState5 == HIGH) {     

    // turn LED on:    

 

    tone(8, NOTE_GS3);

  } 

  else {

 

    noTone (8);

  }

  if (buttonState6 == HIGH) {     

 

    tone(8, NOTE_B3);

  } 

  else {

 

    noTone (8);

  }

  if (buttonState7 == HIGH) {     

    // turn LED on:    

 

    tone(8, NOTE_C4);

  } 

  else {

 

    noTone (8);

  }

  if (buttonState8 == HIGH) {     

    // turn LED on:    

 

    tone(8, NOTE_C3);

  } 

  else {

 

    noTone (8);

  }

 

}

 

 

//pitches.h class (taken from lab)

 

/*************************************************

 * Public Constants

 *************************************************/

 

#define NOTE_B0  31

#define NOTE_C1  33

#define NOTE_CS1 35

#define NOTE_D1  37

#define NOTE_DS1 39

#define NOTE_E1  41

#define NOTE_F1  44

#define NOTE_FS1 46

#define NOTE_G1  49

#define NOTE_GS1 52

#define NOTE_A1  55

#define NOTE_AS1 58

#define NOTE_B1  62

#define NOTE_C2  65

#define NOTE_CS2 69

#define NOTE_D2  73

#define NOTE_DS2 78

#define NOTE_E2  82

#define NOTE_F2  87

#define NOTE_FS2 93

#define NOTE_G2  98

#define NOTE_GS2 104

#define NOTE_A2  110

#define NOTE_AS2 117

#define NOTE_B2  123

#define NOTE_C3  131

#define NOTE_CS3 139

#define NOTE_D3  147

#define NOTE_DS3 156

#define NOTE_E3  165

#define NOTE_F3  175

#define NOTE_FS3 185

#define NOTE_G3  196

#define NOTE_GS3 208

#define NOTE_A3  220

#define NOTE_AS3 233

#define NOTE_B3  247

#define NOTE_C4  262

#define NOTE_CS4 277

#define NOTE_D4  294

#define NOTE_DS4 311

#define NOTE_E4  330

#define NOTE_F4  349

#define NOTE_FS4 370

#define NOTE_G4  392

#define NOTE_GS4 415

#define NOTE_A4  440

#define NOTE_AS4 466

#define NOTE_B4  494

#define NOTE_C5  523

#define NOTE_CS5 554

#define NOTE_D5  587

#define NOTE_DS5 622

#define NOTE_E5  659

#define NOTE_F5  698

#define NOTE_FS5 740

#define NOTE_G5  784

#define NOTE_GS5 831

#define NOTE_A5  880

#define NOTE_AS5 932

#define NOTE_B5  988

#define NOTE_C6  1047

#define NOTE_CS6 1109

#define NOTE_D6  1175

#define NOTE_DS6 1245

#define NOTE_E6  1319

#define NOTE_F6  1397

#define NOTE_FS6 1480

#define NOTE_G6  1568

#define NOTE_GS6 1661

#define NOTE_A6  1760

#define NOTE_AS6 1865

#define NOTE_B6  1976

#define NOTE_C7  2093

#define NOTE_CS7 2217

#define NOTE_D7  2349

#define NOTE_DS7 2489

#define NOTE_E7  2637

#define NOTE_F7  2794

#define NOTE_FS7 2960

#define NOTE_G7  3136

#define NOTE_GS7 3322

#define NOTE_A7  3520

#define NOTE_AS7 3729

#define NOTE_B7  3951

#define NOTE_C8  4186

#define NOTE_CS8 4435

#define NOTE_D8  4699

#define NOTE_DS8 4978

 

Demo video 

 

 

Future Extensions 

 

     The main thing that i wish i had time for was LEDs. I wanted to put three LEDs on each side of the box and have them light up when a button is pressed. I even had this working for one button but I did not have enough time for the rest, so i decided to get rid of that single button and leave this idea as a future extension. Another thing that i would like to do is amplify the sound.

 

Comments (1)

Jessica Faruque said

at 4:35 pm on Aug 20, 2013

It is great to hear about how you ended up picking an 8-bit piano for your final project! We enjoyed hearing about how you formulated a concept because you were reminded by something else you liked -- i.e. Benjamin William's spy gear. We really like how you have a clear definition of your audience as DJ's that like to experiment with electronic sounds.

Your Verplanck diagram and paper prototypes are great to see. We liked how you made a prototype that was quick and easy to build, so that you could refine and iterate quickly on your concept. We liked how you mentioned your design considerations such as simplicity, and wish we could see more discussion of that.

We liked your prototype photo. We wish you had incorporated more description of what each of the components of your prototype are, so future students and viewers unfamiliar with your system could better understand what it was doing. We also liked your state diagram, and liked the simplicity that you used in your design. We wish you had provided some captions for your state diagram so as to make it more clear to understand.

We also wish that you had more description of the challenges you faced in making this project. This would be great for future students to know, so that they are better able to solve problems and avoid any pitfalls you faced.

Your demo video was great, and provided a good overview of everything that your player could do. We really enjoyed how your final prototype came together!

This was a great project, and we hope that you will be able to put it on a perfboard someday. We hope you had fun in EE47!

- Jessica, David, Vivien, Matt, Kevin

You don't have permission to comment on this page.