Keyboard Instrument Midterm project

My midterm project was going to be Arduino Uno connected to Nintendo wii nunchuck. The idea was the wii nunchuck would be used to control LED lights, however I spent to much hours trying to figure out how to put it together along with the code and was unsuccessful with the idea. I decided to move on to something else in the arduino project book I felt I could not go wrong with that idea. I choose Keyboard instrument project number 7.

material used for the project

4 switches (push buttons)

4 resistor (10 klohm resistor, 1 megohm resistor and 220 resistor)

piezo (round and black on breadboard)

jumper wire 8


this idea was inspire by someone else blog

The objective:

Lay down card box onto a flat surface. Solder the jumper wire to the resistor and tape it under aluminum foil and when the arduino is plug into personal computer it would play a sound. the sound would depend on how many output you put in the program. The breadboard, piezo and buttons would be eliminated from the project design.

Keyboard Instrument code and explanation included

int buttons [6];                                //set up an array with 6 integers, declare the buttons

int buttons [0] = 2;                        // give the first element of the array the value 2. when button is off (0) = 2

int notes [] = {262,294,330,349};              // list of frequencies you would want for each button

void setup() {                                                  //
void loop(){
int keyVal = analogRead(A0};                      //declare a variable to hold the value read on pin A0.
Serial.println(keyVal);                                    //Each switch has different resistor connected to value                                                                                                connecting it to the power.
if(keyVal == 1023) {                                        //Each value is sent to serial. println and sent to the computer
tone(8, notes[0];                                              //if else statement give it value different tone.
else if (keyVal >= 990 && keyVal <=1010) {
tone (8,notes [1];
else if(keyVal >=505 && keyVal <= 515){
tone (8, notes[2];
else if(keyVal >= 5 && keyVal <= 10){
tone (8, notes [3];
noTone(8);                                                                           //stop playing when there is no button being                                                                                                                  pressed.

Conclusion: program did not work, as a result I was not able to follow through with my objective. I am not sure where the issue coming from.

Toubleshooting steps: I took everything apart and put together the first program in the arduino project book. The program did work when I change sides of the breadboard I was using. Afterward I design the keyboard instrument again and reset the arduino board and I still have nothing.  I had the same program with previous project on my blog.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s