#define C 2093
#define CS 2217
#define D 2400
#define DS 2500
#define E 2602
#define F 2745
#define FS 3010
#define G 3135
#define GS 3322
#define A 3520
#define AS 3729
#define B 3951
#define HC 4186.01
#define HCS 4435
#define HD 4750
#define HDS 4900
#define HE 5275
int noteDuration = 20;
int Note_A = A;
int Note_AS = AS;
int Note_B = B;
int Note_C = C;
int Note_CS = CS;
int Note_D = D;
int Note_DS = DS;
int Note_E = E;
int Note_F = F;
int Note_FS = FS;
int Note_G = G;
int Note_GS = GS;
int Note_HC = HC;
int Note_HCS = HCS;
int Note_HD = HD;
int Note_HDS = HDS;
int Note_HE = HE;
void setup() {
pinMode (2, INPUT_PULLUP);
pinMode (3, INPUT_PULLUP);
pinMode (4, INPUT_PULLUP);
pinMode (5, INPUT_PULLUP);
pinMode (6, INPUT_PULLUP);
pinMode (7, INPUT_PULLUP);
pinMode (8, INPUT_PULLUP);
pinMode (9, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
if(digitalRead(2) == LOW) {
Serial.println("HIGH");
tone (10, Note_C, noteDuration);
}
else {
noTone;
Serial.println("LOW");
}
if(digitalRead(3) == LOW) {
tone (10, Note_CS, noteDuration);
}
else {
noTone;
}
if(digitalRead(4) == LOW) {
tone (10, Note_D, noteDuration);
}
else {
noTone;
}
if(digitalRead(5) == LOW) {
tone (10, Note_DS, noteDuration);
}
else {
noTone;
}
if(digitalRead(6) == LOW) {
tone (10, Note_E, noteDuration);
}
else {
noTone;
}
if(digitalRead(7) == LOW) {
tone (10, Note_F, noteDuration);
}
else {
noTone;
}
if(digitalRead(8) == LOW) {
tone (10, Note_FS, noteDuration);
}
else {
noTone;
}
if(digitalRead(9) == LOW) {
tone (10, Note_G, noteDuration);
}
else {
noTone;
}
}
/* Code for second arduino
#define C 2093
#define CS 2217
#define D 2400
#define DS 2500
#define E 2602
#define F 2745
#define FS 3010
#define G 3135
#define GS 3322
#define A 3520
#define AS 3729
#define B 3951
#define HC 4186.01
#define HCS 4435
#define HD 4750
#define HDS 4900
#define HE 5275
int noteDuration = 20;
int Note_A = A;
int Note_AS = AS;
int Note_B = B;
int Note_C = C;
int Note_CS = CS;
int Note_D = D;
int Note_DS = DS;
int Note_E = E;
int Note_F = F;
int Note_FS = FS;
int Note_G = G;
int Note_GS = GS;
int Note_HC = HC;
int Note_HCS = HCS;
int Note_HD = HD;
int Note_HDS = HDS;
void setup() {
pinMode (2, INPUT_PULLUP);
pinMode (3, INPUT_PULLUP);
pinMode (4, INPUT_PULLUP);
pinMode (5, INPUT_PULLUP);
pinMode (6, INPUT_PULLUP);
pinMode (7, INPUT_PULLUP);
pinMode (8, INPUT_PULLUP);
pinMode (9, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
if(digitalRead(2) == LOW) {
Serial.println("HIGH");
tone (12, Note_GS, noteDuration);
}
else {
noTone;
Serial.println("LOW");
}
if(digitalRead(3) == LOW) {
tone (12, Note_A, noteDuration);
}
else {
noTone;
}
if(digitalRead(4) == LOW) {
tone (12, Note_AS, noteDuration);
}
else {
noTone;
}
if(digitalRead(5) == LOW) {
tone (12, Note_B, noteDuration);
}
else {
noTone;
}
if(digitalRead(6) == LOW) {
tone (12, Note_BS, noteDuration);
}
else {
noTone;
}
if(digitalRead(7) == LOW) {
tone (12, Note_HC, noteDuration);
}
else {
noTone;
}
if(digitalRead(8) == LOW) {
tone (12, Note_HD, noteDuration);
}
else {
noTone;
}
if(digitalRead(9) == LOW) {
tone (12, Note_HDS, noteDuration);
}
else {
noTone;
}
}
*/
Comments