int redPin = 3;// color rojo al pin 3 en el Arduino
int greenPin = 5;// color Verde a la clavija 5 en el Arduino
int BluePin = 6;// color azul a la patilla 6 en el Arduino
// En la sección de configuración necesitamos definir ‘redPin’,‘greenPin’ y ‘BluePin’ como salidas.
void setup () {
pinMode (redPin, OUTPUT);
pinMode (greenPin, OUTPUT);
pinMode (BluePin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
setColor (255, 0, 0); // Color rojo
delay(1000);
setColor (0, 255, 0); // Color verde
delay(1000);
setColor (0, 0, 255); // Color azul
delay(1000);
setColor (255, 255, 255); // Color blanco
delay(1000);
setColor (180, 0, 255); // Color púrpura
delay(1000);
}
void setColor (int redValue, int greenValue, int blueValue) {
analogWrite (redPin, redValue);
analogWrite (greenPin, greenValue);
analogWrite (BluePin, blueValue);}