Category:

Ardunio

Title:

Basic Piano with Ardunio

The buzzer is a simple but ingenious ardunio component. With buzzer you can get different levels of sounds. Do, Re, Mi, Fa, Sol, La, Si, Do... yes you can take these basic notes with the buzzer. And you can play songs using these notes. Of course at a simple level. A simple piano was created in the following event created with Ardunio. It is possible to add new sounds to this work. When you search the Internet, you can reach the vibration values ​​of these sounds. And you can create more original and deeper studies.

Project Scheme


Necessary materials

  • Ardunio Uno
  • Button x 8
  • 10k Ressistor x 8
  • Breadboard
  • Piezo Buzzer
  • Jumper cables


Ardunio Source Code

//First we define the vibration values of the notes
#define dob  264 //written dob for not to interfere do command
#define re   297
#define mi   330
#define fa   352
#define sol  396
#define la   440
#define si   495
#define dot  528// thin do

// we set the pins to which the buttons are connected
const int Dobbutton = 2;
const int Rebutton = 3;
const int Mibutton = 4;
const int Fabutton = 5;
const int Solbutton = 6;
const int Labutton = 7;
const int Sibutton = 8;
const int Dotbutton = 9;

//we define the necessary variables to determine whether the buttons are pressed

int buttonDobstatus = 0;
int buttonRestatus = 0;
int buttonMistatus = 0;
int buttonFastatus = 0;
int buttonSolstatus = 0;
int buttonLastatus = 0;
int buttonSistatus = 0;
int buttonDotstatus = 0;

void setup() 

{ 
//We set the INPUT value as we get the value from the buttons
    pinMode(Dobbutton, INPUT);
    pinMode(Rebutton, INPUT);
    pinMode(Mibutton , INPUT);
    pinMode(Fabutton, INPUT);
    pinMode(Solbutton, INPUT);
    pinMode(Labutton, INPUT);
    pinMode(Sibutton , INPUT);
   pinMode(Dotbutton, INPUT);

 }

void loop() {
    //We are listening to the status of pressing the buttons in the loop
    buttonDobstatus = digitalRead(Dobbutton);
    buttonRestatus = digitalRead(Rebutton);
    buttonMistatus = digitalRead(Mibutton);
    buttonFastatus = digitalRead(Fabutton);
    buttonSolstatus = digitalRead(Solbutton);
    buttonLastatus = digitalRead(Labutton);
    buttonSistatus = digitalRead(Sibutton);
    buttonDotstatus = digitalRead(Dotbutton);

    // If the buttons are pressed, the buzzer will receive the required notes

      if (buttonDobstatus == HIGH) {
           tone(10, dok, 100); //burada 10 buzzerin bağlı olduğu pini, dok sesin değerini, 100 çalma süresini ifade ediyor

       }

       if (buttonRestatus == HIGH) {
           tone(10, re, 100);

       }

       if (buttonMistatus == HIGH) {
           tone(10, mi, 100);

       }

       if (buttonFastatus == HIGH) {

           tone(10, fa, 100);

       }

       if (buttonSolstatus == HIGH) {

           tone(10, sol, 100);

       }

       if (buttonLadstatus == HIGH) {

           tone(10, la, 100);

       }

       if (buttonSistatus == HIGH) {

           tone(10, si, 100);

       }

       if (buttonDotstatus == HIGH) {

           tone(10, doi, 100);

       }   

 }

739 views
COMMENTS