const int redPin = 6; // Pin connected to the red channel of RGB LED
const int greenPin = 7; // Pin connected to the green channel of RGB LED
const int bluePin = 8; // Pin connected to the blue channel of RGB LED
void setup() {
pinMode(5, OUTPUT);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
digitalWrite(5, HIGH);
delay(1000);
digitalWrite(5, LOW);
delay(1000);
// Set the LED to red
setColor(255, 0, 0);
delay(1000);
// Set the LED to green
setColor(0, 255, 0);
delay(1000);
// Set the LED to blue
setColor(0, 0, 255);
delay(1000);
}
void setColor(int redValue, int greenValue, int blueValue) {
digitalWrite(redPin, redValue);
digitalWrite(greenPin, greenValue);
digitalWrite(bluePin, blueValue);
}
Loading
st-nucleo-l031k6
st-nucleo-l031k6