laurenkoi
Published

Arduino Project 7: Keyboard Instrument

Using arrays to make different noises. Using the switches, this is able to crate noise like an instrument.

BeginnerWork in progress1 hour258
Arduino Project 7: Keyboard Instrument

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×1
Buzzer, Piezo
Buzzer, Piezo
×1
Through Hole Resistor, 10 kohm
Through Hole Resistor, 10 kohm
×1
Through Hole Resistor, 0.1 Gohm
Through Hole Resistor, 0.1 Gohm
×1
Resistor 220 ohm
Resistor 220 ohm
×1

Story

Read more

Schematics

Keyboard Instrument Video

Fritzing

Schematics

Code

Keyboard Instrument Code

Arduino
const int PinInterruptor=8;
unsigned long PreviousTime=0;
int InterruptorState=0;
int PreviousStateInterruptor=0;
int Led=2;
long TimeIntervalocadaLed=5000;
int c=0;
void setup() {
 for(int x=2;x<8;x++){
  pinMode(x,OUTPUT); //Stablishing all the LEDs as outputs
 }
 pinMode(PinInterruptor,INPUT); //Stablishing the switch as an input
}

void loop() {
 unsigned long ActualTime=millis();
 if(ActualTime-PreviousTime>TimeIntervalocadaLed){ 
  PreviousTime=ActualTime;
  digitalWrite(Led,HIGH);
  Led++;
  if(Led==7){ /
    delay(2500);
    c=0;
    while(c<5){
     for(int x=2;x<8;x++){
      digitalWrite(x,LOW);
     }
     delay(500);
     for(int x=2;x<8;x++){
      digitalWrite(x,HIGH);
     } 
     delay(500);
     c++;  
    }
  }
 }
 InterruptorState=digitalRead(PinInterruptor); //Read sensor state
  if(InterruptorState !=PreviousStateInterruptor){ //Puting all variables at zero if the state has changed
    for(int x=2;x<8;x++){
     digitalWrite(x,LOW);
    }
    Led=2;
    PreviousTime=ActualTime;
  }
  PreviousStateInterruptor=InterruptorState; //Stablishing the actual state as the previous one
}

Credits

laurenkoi
13 projects • 1 follower
Contact

Comments

Please log in or sign up to comment.