Project in progress

Arduino Keyboard © GPL3+

As a musician and music passionate, this little Keyboard is my first (but not last) Arduino project. Hope you have fun with it :)

  • 197 views
  • 0 comments
  • 4 respects

Components and supplies

About this project

Didn't know what to do as my first Arduino Project, so i thought of starting out with something little and temporary, like this Arduino Keyboard which you can edit as you like.

Again, hope you have fun with it. :)

Schematics

Keyboard schematics
And that's how you should wire it, standing to the code
Cattura wcebhdlt9y

Code

Arduino Keyboard codeC/C++
That's the code that will make your keyboard play
#include "pitches.h" //Notes are stored into this library

int C = 7; //First button on pin 7
int D = 8; //Second button on pin 8
int E = 9; //Third button on pin 9
int F = 10; //Fourth button on pin 10
int G = 11; //Fifth button on pin 11
int A = 12; //Sixth button on pin 12
int B = 13; //Seventh button on pin 13

int c[] = {N_C5}; //Plays C Note
int d[] = {N_D5}; //Plays D Note
int e[] = {N_E5}; //Plays E Note
int f[] = {N_F5}; //Plays F Note
int g[] = {N_G5}; //Plays G Note
int a[] = {N_A5}; //Plays A Note
int b[] = {N_B5}; //Plays B Note

int duration(500); //Every note lasts 500 milliseconds. You can change it as you like

void setup() {
  //Set every button as an INPUT_PULLUP
  pinMode(C, INPUT_PULLUP);
  pinMode(D, INPUT_PULLUP);
  pinMode(E, INPUT_PULLUP);
  pinMode(F, INPUT_PULLUP);
  pinMode(G, INPUT_PULLUP);
  pinMode(A, INPUT_PULLUP);
  pinMode(B, INPUT_PULLUP);
}

void loop() {
  if (digitalRead(C) == LOW) { //Reads button state when pressed
    for (int Note = 0; Note < 1; Note++) {
      tone(6, c[Note], duration); //Plays note on pin 6, where the Buzzer is connected (change it if you connected it on another pin)
    }
  }
  if (digitalRead(D) == LOW) {
    for (int Note = 0; Note < 1; Note++) {
      tone(6, d[Note], duration); 
    }
  }
  if (digitalRead(E) == LOW) {
    for (int Note = 0; Note < 1; Note++) {
      tone(6, e[Note], duration);
    }
  }
  if (digitalRead(F) == LOW) {
    for (int Note = 0; Note < 1; Note++) {
      tone(6, f[Note], duration);
    }
  }
  if (digitalRead(G) == LOW) {
    for (int Note = 0; Note < 1; Note++) {
      tone(6, g[Note], duration);
    }
  }
  if (digitalRead(A) == LOW) {
    for (int Note = 0; Note < 1; Note++) {
      tone(6, a[Note], duration);
    }
  }
  if (digitalRead(B) == LOW) {
    for (int Note = 0; Note < 1; Note++) {
      tone(6, b[Note], duration);
    }
  }
}

Comments

Similar projects you might like

LED Cube

Project tutorial by Praditha Alwis

  • 96 views
  • 0 comments
  • 3 respects

DHT11 Temperature/Humidity Sensor

Project tutorial by Zach Haslam

  • 133 views
  • 0 comments
  • 4 respects

Makers (Cubecon) #1 Infrared Transmit & Infrared Receive

Project in progress by Alpha

  • 61 views
  • 0 comments
  • 3 respects

Windows PC Lock/Unlock Using RFID

Project tutorial by Prasanth K S

  • 6,184 views
  • 6 comments
  • 28 respects

DINternet IoT Controller

Project in progress by Craig Hissett

  • 175 views
  • 0 comments
  • 2 respects
Add projectSign up / Login