#define PIN1_RED 25 // GIOP25
#define PIN1_GREEN 26 // GIOP26
#define PIN1_BLUE 27 // GIOP27
#define PIN2_RED 35 // GIOP35
#define PIN2_GREEN 32 // GIOP32
#define PIN2_BLUE 33 // GIOP33
#define PIN3_RED 36 // GIOP36
#define PIN3_GREEN 39 // GIOP39
#define PIN3_BLUE 34 // GIOP34
#define R_channel 0
#define G_channel 1
#define B_channel 2
#define pwm_frequency 5000 // frequence pwm
#define pwm_resolution 8 // 8 bit resolution
//##############################
void setup()
{
pinMode(PIN1_RED, OUTPUT);
pinMode(PIN1_GREEN, OUTPUT);
pinMode(PIN1_BLUE, OUTPUT);
pinMode(PIN2_RED, OUTPUT);
pinMode(PIN2_GREEN, OUTPUT);
pinMode(PIN2_BLUE, OUTPUT);
pinMode(PIN3_RED, OUTPUT);
pinMode(PIN3_GREEN, OUTPUT);
pinMode(PIN3_BLUE, OUTPUT);
ledcAttachPin (PIN1_RED, R_channel);
ledcAttachPin (PIN1_GREEN, G_channel);
ledcAttachPin (PIN1_BLUE, B_channel);
ledcAttachPin (PIN2_RED, R_channel);
ledcAttachPin (PIN2_GREEN, G_channel);
ledcAttachPin (PIN2_BLUE, B_channel);
ledcAttachPin (PIN3_RED, R_channel);
ledcAttachPin (PIN3_GREEN, G_channel);
ledcAttachPin (PIN3_BLUE, B_channel);
ledcSetup(R_channel, pwm_frequency,pwm_resolution);
ledcSetup(G_channel, pwm_frequency,pwm_resolution);
ledcSetup(B_channel, pwm_frequency,pwm_resolution);
}
void loop()
{
//Correspondance des frequences des notes en hertz (octave à 0) et la couleurs
Serial.println (note.value);
if (note.value == 36) //Do
{
setColor(237, 0, 0); // RGB_Ecarlate
}
else if (note.value == 37) //Do#
{
setColor(255, 0, 0); //RGB rouge
}
else if (note.value == 38) //Ré_Orange
{
setColor(255, 165, 0); //RGB_Ornage
}
else if (note.value == 39) //Ré#_Jaune
{
setColor(255, 255, 0); //RGB_Jaune
}
else if (note.value == 40) //Mi_Citron
{
setColor(0, 255, 0); //RGB_Citron
}
else if (note.value == 41) //Fa_Vert
{
setColor(0, 128, 0); //RGB_Vert
}
else if (note.value == 42) //Fa#_Turquoise
{
setColor(0, 206, 209); //RGB_Turquoise
}
else if (note.value == 43) //Sol
{
setColor(0, 255, 255); //RGB_Cyan
}
else if (note.value == 44) //Sol#_Indigo
{
setColor(75, 0, 130); //RGB_Indigo
}
else if (note.value == 45) //La_Bleu
{
setColor(0, 0, 255); //RGB_Bleu
}
else if (note.value == 46) //La#_Pourpre
{
setColor(176, 224, 230); //RGB_Pourpre
}
else if (note.value == 47) //Si
{
setColor(255, 0, 255); //RGB_Mangenta
}
}
void setColor(int R, int G, int B)
{
ledcWrite(R_channel,R);
ledcWrite(G_channel,G);
ledcWrite(B_channel,B);
}
Vous avez entré un nom de page invalide, avec un ou plusieurs caractères suivants :
< > @ ~ : * € £ ` + = / \ | [ ] { } ; ? #