Project in progress
Piano/Synth

Piano/Synth © GPL3+

This 12 pushbutton piano plays the 4th octave with an optional added 3rd and 5th octave, controls note length and pitch with two pots.

  • 2,991 views
  • 0 comments
  • 17 respects

Components and supplies

Apps and online services

About this project

I was trying to build a simple one octave piano when I realized I still had pins left to add more funtions to it so I went for it.

It has 12 push buttons acting as the piano keys (i suggest painting them black n white accordingly for visual effect). 2 slide buttons that actívate an octave up and an octave up note for each button pushed and two potentiometers, one of them controls the note length (te piano will loop the note as long as its button is pushed) and the othe pot controls a pitch bend (which actually adds the analog input value to the notes' frequency)

I actually recycled most of the components used in this proyect from broken electronic apparatus. All push buttons, and both slide buttons were taken from an old cd player, pots were taken from a broken radio I found on the Street and the speaker is actually a buzzer from an old tube phone.

I´ve had a lot of fun with this Little proyect (i am quite new to the programming and Arduino universo) and hope you will too, any feedback or criticism you have on my wiring or coding is more tan welcome!

Code

PIANO.inoC/C++
// nomenclatura de pines digitales al que corresponde cada nota
int C  = 2;
int CS = 3;
int D  = 4;
int DS = 5;
int E  = 6;
int F  = 7;
int FS = 8;
int G  = 9;
int GS = 10;
int A  = 11;
int AS = 12;
int B  = 13;
int octabajo = 0;
int octarriba = 1;
int tiempo = analogRead(A4);
int pitch_bend = analogRead(A5);

//nomenclatura de referencia de frecuencia por nota

int c  = 262;
int cs = 277;
int d  = 294;
int ds = 311;
int e  = 330;
int f  = 349;
int fs = 370;
int g  = 392;
int gs = 415;
int a  = 440;
int as = 466;
int b  = 494;

void setup() {
  // INPUT CONFIG
  pinMode(C, INPUT_PULLUP);
  pinMode(CS, INPUT_PULLUP);
  pinMode(D, INPUT_PULLUP);
  pinMode(DS, INPUT_PULLUP);
  pinMode(E, INPUT_PULLUP);
  pinMode(F, INPUT_PULLUP);
  pinMode(FS, INPUT_PULLUP);
  pinMode(G, INPUT_PULLUP);
  pinMode(GS, INPUT_PULLUP);
  pinMode(A, INPUT_PULLUP);
  pinMode(AS, INPUT_PULLUP);
  pinMode(B, INPUT_PULLUP);
  pinMode(octabajo, INPUT_PULLUP);
  pinMode(octarriba, INPUT_PULLUP);
  pinMode(A4, INPUT);
  // OUTPUT CONFIG
  pinMode(A2, OUTPUT);
  // start serial port
  Serial.begin(9600);
}



void loop() {
 
  // put your main code here, to run repeatedly:
  digitalRead(0);
  digitalRead(1);
 
  Serial.println(analogRead(A4));

  if (!digitalRead(C)) {
    tone(A2, c+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(C);
  }
  if (!digitalRead(C)&&!digitalRead(octabajo)) {
    tone(A2, c/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(C);
  }
  if (!digitalRead(C)&&!digitalRead(octarriba)) {
    tone(A2, c*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(C);
  }


  digitalRead(CS);
  if (!digitalRead(CS)) {
    tone(A2, cs+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(CS);
  }
  if (!digitalRead(CS)&&!digitalRead(octabajo)) {
    tone(A2, cs/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(CS);
  }
  if (!digitalRead(CS)&&!digitalRead(octarriba)) {
    tone(A2, cs*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(CS);
  }

  digitalRead(D);
  if (!digitalRead(D)) {
    tone(A2, d+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(D);
  }
  if (!digitalRead(D)&&!digitalRead(octabajo)) {
    tone(A2, d/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(D);
  }
  if (!digitalRead(D)&&!digitalRead(octarriba)) {
    tone(A2, d*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(D);
  }

  digitalRead(DS);
  if (!digitalRead(DS)) {
    tone(A2, ds+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(DS);
  }
  if (!digitalRead(DS)&&!digitalRead(octabajo)) {
    tone(A2, ds/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(DS);
  }
  if (!digitalRead(DS)&&!digitalRead(octarriba)) {
    tone(A2, ds*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(DS);
  }

  digitalRead(E);
  if (!digitalRead(E)) {
    tone(A2, e+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(E);
  }
  if (!digitalRead(E)&&!digitalRead(octabajo)) {
    tone(A2, e/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(E);
  }
  if (!digitalRead(E)&&!digitalRead(octarriba)) {
    tone(A2, e*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(E);
  }

  digitalRead(F);
  if (!digitalRead(F)) {
    tone(A2, f+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(F);
  }if (!digitalRead(F)&&!digitalRead(octabajo)) {
    tone(A2, f/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(F);
  }
  if (!digitalRead(F)&&!digitalRead(octarriba)) {
    tone(A2, f*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(F);
  }

  digitalRead(FS);
  if (!digitalRead(FS)) {
    tone(A2, fs+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(FS);
  }
  if (!digitalRead(FS)&&!digitalRead(octabajo)) {
    tone(A2, fs/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(FS);
  }
  if (!digitalRead(FS)&&!digitalRead(octarriba)) {
    tone(A2, fs*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(FS);
  }

  digitalRead(G);
  if (!digitalRead(G)) {
    tone(A2, g+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(G);
  }
  if (!digitalRead(G)&&!digitalRead(octabajo)) {
    tone(A2, g/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(G);
  }
  if (!digitalRead(G)&&!digitalRead(octarriba)) {
    tone(A2, g*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(G);
  }

  digitalRead(GS);
  if (!digitalRead(GS)) {
    tone(A2, gs+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(GS);
  }
  if (!digitalRead(GS)&&!digitalRead(octabajo)) {
    tone(A2, gs/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(GS);
  }
  if (!digitalRead(GS)&&!digitalRead(octarriba)) {
    tone(A2, gs*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(GS);
  }

  digitalRead(A);
  if (!digitalRead(A)) {
    tone(A2, a+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(A);
  }
  if (!digitalRead(A)&&!digitalRead(octabajo)) {
    tone(A2, a/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(A);
  }
  if (!digitalRead(A)&&!digitalRead(octarriba)) {
    tone(A2, a*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(A);
  }

  digitalRead(AS);
  if (!digitalRead(AS)) {
    tone(A2, as+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(AS);
  }
  if (!digitalRead(AS)&&!digitalRead(octabajo)) {
    tone(A2, as/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(AS);
  }
  if (!digitalRead(AS)&&!digitalRead(octarriba)) {
    tone(A2, as*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(AS);
  }

  digitalRead(B);
  if (!digitalRead(B)) {
    tone(A2, b+(analogRead(A5)/5));
    delay(analogRead(A4));
    digitalRead(B);
  }
  if (!digitalRead(B)&&!digitalRead(octabajo)) {
    tone(A2, b/2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(B);
  }
  if (!digitalRead(B)&&!digitalRead(octarriba)) {
    tone(A2, b*2+((analogRead(A5)/5)));
    delay(analogRead(A4));
    digitalRead(B);
  }
  
  noTone(A2);

  
  }

Schematics

captura_2SaLCvvBdd.JPG
Captura 2salcvvbdd

Comments

Similar projects you might like

Scorbot ER-V+ Controller & Simulator Design

Project tutorial by Amit Nandi (BigWiz)

  • 534 views
  • 2 comments
  • 5 respects

GPS Datalogger, Spatial Analysis, and Azure IoT Hub.

Project tutorial by Shawn Cruise

  • 20,163 views
  • 4 comments
  • 75 respects

Newbie Music Player

Project in progress by Michael Marinis

  • 4,297 views
  • 2 comments
  • 13 respects

Arduino Project: Burglar Zone Input Tester

Project tutorial by Cezarjar

  • 1,560 views
  • 2 comments
  • 9 respects

Displaying Sensor Values on LCD

by Wimpie van den Berg

  • 56,440 views
  • 5 comments
  • 41 respects

DrumCube, an Arduino Robot Drummer

Project showcase by FrancoMolina

  • 8,407 views
  • 27 comments
  • 70 respects
Add projectSign up / Login