0% found this document useful (0 votes)
9 views3 pages

Piano Arduino

This document outlines an Arduino piano project using a piezo buzzer and LED. It defines various button inputs for musical notes and sets up a loop to play corresponding tones when buttons are pressed. The LED lights up while a note is played and turns off when no tone is produced.

Uploaded by

new_felgon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Piano Arduino

This document outlines an Arduino piano project using a piezo buzzer and LED. It defines various button inputs for musical notes and sets up a loop to play corresponding tones when buttons are pressed. The LED lights up while a note is played and turns off when no tone is produced.

Uploaded by

new_felgon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PRACTICA # 1 PIANO ARDUINO

CIRCUITO
int PIEZO = 11;
int LED = 13;

int BUTTON_C = 2;
int BUTTON_D = 3;
int BUTTON_E = 4;
int BUTTON_F = 5;
int BUTTON_G = 6;
int BUTTON_A = 7;
int BUTTON_B = 8;
int BUTTON_C2 = 9;

int MUSICAL = 10;

void setup()
{
for(int i = 2; i<=10;i++)
{
pinMode(i, INPUT_PULLUP);
}

pinMode(LED, OUTPUT);
}
void loop()
{
while(digitalRead(BUTTON_C) == LOW)
{
tone(PIEZO, 262, 100);
digitalWrite(LED,HIGH);
}
while(digitalRead(BUTTON_D) == LOW)
{
tone(PIEZO, 294, 100);
digitalWrite(LED,HIGH);
}

while(digitalRead(BUTTON_E) == LOW)
{
tone(PIEZO, 330, 100);
digitalWrite(LED,HIGH);
}

while(digitalRead(BUTTON_F) == LOW)
{
tone(PIEZO, 349, 100);
digitalWrite(LED,HIGH);
}

while(digitalRead(BUTTON_G) == LOW)
{
tone(PIEZO, 392, 100);
digitalWrite(LED,HIGH);
}

while(digitalRead(BUTTON_A) == LOW)
{
tone(PIEZO, 440, 100);
digitalWrite(LED,HIGH);
}

while(digitalRead(BUTTON_B) == LOW)
{
tone(PIEZO, 494, 100);
digitalWrite(LED,HIGH);
}

while(digitalRead(BUTTON_C2) == LOW)
{
tone(PIEZO, 523, 100);
digitalWrite(LED,HIGH);
}

noTone(PIEZO);
digitalWrite(LED,LOW);

You might also like