La led RGB utilisée: http://www.selectronic.fr/upload/produit/fichetechnique/0567.pdf
Avec l'arduino, la tension d'entrée est de 5V. Pour chaque patte R, G, B de la LED, il faut calculer la résistance nécessaire avec $R = \frac{(Valim - Vref)}{I}$
- rgb_led.pde
const char steps[6][3] = { {0, 1, 0}, // start from red (255, 0, 0) and go to yellow (255, 255, 0) {-1, 0, 0}, // go to green (0, 255, 0) {0, 0, 1}, // go to cyan (0, 255, 255) {0, -1, 0}, // go to blue (0, 0, 255) {1, 0, 0}, // go to magenta (255, 0, 255) {0, 0, -1}, // go back to red (255, 0, 0) }; int rpin = 9; int gpin = 10; int bpin = 11; int pot_pin = 0; void setup() // run once, when the sketch starts { pinMode(rpin, OUTPUT); // sets the pin as output pinMode(gpin, OUTPUT); // sets the pin as output pinMode(bpin, OUTPUT); // sets the pin as output } void loop() // run over and over again { unsigned char color[3] = {255, 0, 0 }; // start by red int s = 2; // bigger means faster fadind less smoother for (int c = 0; c < 6; ++c) { // go through the 6 colors for (int i = 0; i < 256-s; i += s) { color[0] += steps[c][0]*s; color[1] += steps[c][1]*s; color[2] += steps[c][2]*s; analogWrite(rpin, color[0]); analogWrite(gpin, color[1]); analogWrite(bpin, color[2]); /* int val = analogRead(pot_pin); val = (1024-val)/10; val = (val == 0) ? 1 : val; delay(val); */ delay(10); } } }