Line 5: |
Line 5: |
| |Is tv=True | | |Is tv=True |
| |Has name={{PAGENAME}} | | |Has name={{PAGENAME}} |
− | |Has icon=File:mood_lamp_icon.png | + | |Has icon=File:final_keyboard_assembley.jpg |
− | |Has icondesc=Mood Lamp Icon | + | |Has icondesc=Electronic Keyboard Icon |
− | |Has image=File:mood_lamp_image.png | + | |Has image=File:final_keyboard_assembley.jpg |
− | |Has description=Mood Lamp | + | |Has description=Electronic Keyboard |
| | | |
| }} | | }} |
Line 15: |
Line 15: |
| [[{{#show:{{FULLPAGENAME}}|?Has icon|link=none}}|100px|left|top|{{#show: {{FULLPAGENAME}}|?Has icondesc}}]] | | [[{{#show:{{FULLPAGENAME}}|?Has icon|link=none}}|100px|left|top|{{#show: {{FULLPAGENAME}}|?Has icondesc}}]] |
| | | |
− | In this TV, we will be creating an electronic keyboard. | + | In this TV, we will be creating an electronic keyboard. Each key plays a different note, and it cam be configured by programming. |
| | | |
| == Bill of Materials == | | == Bill of Materials == |
Line 47: |
Line 47: |
| | | |
| Using this board, we will assemble the circuit. | | Using this board, we will assemble the circuit. |
− | This build makes heavy use of soldering, so check out the soldering wiki page: INSERT | + | This build makes heavy use of soldering, so check out the soldering wiki page: [[Soldering_Irons]] |
| | | |
| ==ASSEMBLY== | | ==ASSEMBLY== |
Line 163: |
Line 163: |
| In the main window, copy this code: | | In the main window, copy this code: |
| | | |
− | <code style="color: green;">
| + | [[Media:Tone_arduino2.ino]] |
| | | |
− | | + | under tools > board, select Arduino uno. Then, connect a usb cable from the board to the computer. under tools, make sure that the "com port" is set to the listing in the drop down; this is the device on the other end of the usb cable. Then, select upload! |
− | | |
− | #include "pitches.h"
| |
− | #define TONE_PIN A2
| |
− | | |
− | //C major
| |
− | int notes[] = { NOTE_A3, NOTE_B3, NOTE_C4, NOTE_D4, NOTE_E4, NOTE_F4, NOTE_G4, NOTE_A4 };
| |
− | | |
− | //G major
| |
− | //int notes[] = { NOTE_A3, NOTE_B3, NOTE_C4, NOTE_D4, NOTE_E4, NOTE_FS4, NOTE_G4, NOTE_A4 };
| |
− | | |
− | //D major
| |
− | //int notes[] = { NOTE_A3, NOTE_B3, NOTE_CS4, NOTE_D4, NOTE_E4, NOTE_FS4, NOTE_G4, NOTE_A4 };
| |
− | | |
− | //A major
| |
− | //int notes[] = { NOTE_A3, NOTE_B3, NOTE_CS4, NOTE_D4, NOTE_E4, NOTE_FS4, NOTE_GS4, NOTE_A4 };
| |
− | | |
− | //E major
| |
− | //int notes[] = { NOTE_A3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_E4, NOTE_FS4, NOTE_GS4, NOTE_A4 };
| |
− | | |
− | //B major
| |
− | //int notes[] = { NOTE_AS3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_E4, NOTE_FS4, NOTE_GS4, NOTE_AS4 };
| |
− | | |
− | //A minor
| |
− | //int notes[] = { NOTE_GS3, NOTE_AS3, NOTE_C4, NOTE_CS4, NOTE_DS4, NOTE_F4, NOTE_G4, NOTE_GS4 };
| |
− | | |
− | //E minor
| |
− | //int notes[] = { NOTE_GS3, NOTE_AS3, NOTE_C4, NOTE_D4, NOTE_DS4, NOTE_F4, NOTE_G4, NOTE_GS4 };
| |
− | | |
− | //B minor
| |
− | //int notes[] = { NOTE_A3, NOTE_AS3, NOTE_C4, NOTE_D4, NOTE_DS4, NOTE_F4, NOTE_G4, NOTE_A4 };
| |
− | | |
− | | |
− | | |
− | int oldButton = 0;
| |
− | int newButton = 0;
| |
− | | |
− | void setup() {
| |
− | // put your setup code here, to run once:
| |
− | | |
− | }
| |
− | | |
− | void loop() {
| |
− | delay(10);
| |
− |
| |
− | newButton = readButtons();
| |
− |
| |
− | if(oldButton != newButton){
| |
− | oldButton = newButton;
| |
− | | |
− | if(newButton != 0){
| |
− | tone(TONE_PIN, notes[newButton - 1]);
| |
− | }else{
| |
− | noTone(TONE_PIN);
| |
− | }
| |
− |
| |
− | }
| |
− | | |
− | }
| |
− | | |
− | int readButtons() {
| |
− | int button;
| |
− | if (digitalRead(2) == HIGH) { //button 1
| |
− | button = 1;
| |
− | } else if (digitalRead(3) == HIGH) { //button 2
| |
− | button = 2;
| |
− | } else if (digitalRead(4) == HIGH) { //button 3
| |
− | button = 3;
| |
− | } else if (digitalRead(5) == HIGH) { //button 4
| |
− | button = 4;
| |
− | } else if (digitalRead(6) == HIGH) { //button 5
| |
− | button = 5;
| |
− | } else if (digitalRead(7) == HIGH) { //button 6
| |
− | button = 6;
| |
− | } else if (digitalRead(8) == HIGH) { //button 7
| |
− | button = 7;
| |
− | } else if (digitalRead(9) == HIGH) { //button 8
| |
− | button = 8;
| |
− | } else {
| |
− | button = 0;
| |
− | }
| |
− | return button;
| |
− | }
| |
− | | |
− | </code>
| |
− | | |
− | then, create a second tab, and name it ____
| |
− | | |
− | in it, copy this:
| |
− | | |
− | <code style="color: green;">codehere</code>
| |