Hehe now here it is with 8 light 8 notes to 8 buttons! I'm finally getting this solid. Much better, time to celebrate lol. Though I wish I could stick in a potentiometer and bend the notes something like, 'If button pressed while pot is turned this way it will make it D#, turn it the other way this will make it D flat and so on... Also I couldn't send a video with the sound and all maybe I'll post this up some time in YouTube when I feel like it
But now I'm working on a potentiometer and getting several buttons pressed at the same time for chords I'm slowly getting there, but any ideas?
#define NOTE_C4 262
#define NOTE_D4 294
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_G4 392
#define NOTE_A5 440
#define NOTE_B5 493
#define NOTE_C5 523
#define ACTIVATED LOW
const int PIEZO = 37;
const int LED = 13;
const int LEDred1 = 45;
const int LEDyellow1 = 44;
const int LEDgreen1 = 43;
const int LEDblue1 = 42;
const int LEDred2 = 41;
const int LEDyellow2 = 40;
const int LEDgreen2 = 39;
const int LEDblue2 = 38;
//
const int BUTTON_C4 = 53;
const int BUTTON_D4 = 52;
const int BUTTON_E4 = 51;
const int BUTTON_F4 = 50;
const int BUTTON_G4 = 49;
const int BUTTON_A5 = 48;
const int BUTTON_B5 = 47;
const int BUTTON_C5 = 46;
void setup()
{
pinMode(LED,OUTPUT);
pinMode(LEDred1,OUTPUT);
pinMode(BUTTON_C4, INPUT);
digitalWrite(BUTTON_C4,HIGH);
pinMode(LED,OUTPUT);
pinMode(LEDyellow1,OUTPUT);
pinMode(BUTTON_D4, INPUT);
digitalWrite(BUTTON_D4,HIGH);
pinMode(LED,OUTPUT);
pinMode(LEDgreen1,OUTPUT);
pinMode(BUTTON_E4, INPUT);
digitalWrite(BUTTON_E4, HIGH);
pinMode(LED,OUTPUT);
pinMode(LEDblue1, OUTPUT);
pinMode(BUTTON_F4, INPUT);
digitalWrite(BUTTON_F4, HIGH);
//
pinMode(LED,OUTPUT);
pinMode(LEDred2,OUTPUT);
pinMode(BUTTON_G4, INPUT);
digitalWrite(BUTTON_G4,HIGH);
pinMode(LED,OUTPUT);
pinMode(LEDyellow2,OUTPUT);
pinMode(BUTTON_A5, INPUT);
digitalWrite(BUTTON_A5,HIGH);
pinMode(LED,OUTPUT);
pinMode(LEDgreen2,OUTPUT);
pinMode(BUTTON_B5, INPUT);
digitalWrite(BUTTON_B5, HIGH);
pinMode(LED,OUTPUT);
pinMode(LEDblue2, OUTPUT);
pinMode(BUTTON_C5, INPUT);
digitalWrite(BUTTON_C5, HIGH);
digitalWrite(LED,LOW);
}
void loop()
{
while(digitalRead(BUTTON_C4) == ACTIVATED)
{
tone(PIEZO,NOTE_C4);
digitalWrite(LED,HIGH);
digitalWrite(LEDred1,HIGH);
}
while(digitalRead(BUTTON_D4) == ACTIVATED)
{
tone(PIEZO,NOTE_D4);
digitalWrite(LED,HIGH);
digitalWrite(LEDyellow1,HIGH);
}
while(digitalRead(BUTTON_E4) == ACTIVATED)
{
tone(PIEZO,NOTE_E4);
digitalWrite(LED,HIGH);
digitalWrite(LEDgreen1,HIGH);
}
while(digitalRead(BUTTON_F4) == ACTIVATED)
{
tone(PIEZO,NOTE_F4);
digitalWrite(LED,HIGH);
digitalWrite(LEDblue1,HIGH);
}
//
while(digitalRead(BUTTON_G4) == ACTIVATED)
{
tone(PIEZO,NOTE_G4);
digitalWrite(LED,HIGH);
digitalWrite(LEDred2,HIGH);
}
while(digitalRead(BUTTON_A5) == ACTIVATED)
{
tone(PIEZO,NOTE_A5);
digitalWrite(LED,HIGH);
digitalWrite(LEDyellow2,HIGH);
}
while(digitalRead(BUTTON_B5) == ACTIVATED)
{
tone(PIEZO,NOTE_B5);
digitalWrite(LED,HIGH);
digitalWrite(LEDgreen2,HIGH);
}
while(digitalRead(BUTTON_C5) == ACTIVATED)
{
tone(PIEZO,NOTE_C5);
digitalWrite(LED,HIGH);
digitalWrite(LEDblue2,HIGH);
}
{
noTone(PIEZO);
digitalWrite(LED,LOW);
digitalWrite(LEDred1,LOW);
digitalWrite(LEDyellow1,LOW);
digitalWrite(LEDgreen1,LOW);
digitalWrite(LEDblue1,LOW);
digitalWrite(LEDred2,LOW);
digitalWrite(LEDyellow2,LOW);
digitalWrite(LEDgreen2,LOW);
digitalWrite(LEDblue2,LOW);
}
}