const int redButtonPin = 2; // Pin pre červené tlačidlo
const int greenButtonPin = 3; // Pin pre zelené tlačidlo
const int blueButtonPin = 4; // Pin pre modré tlačidlo
const int rgbPinRed = 5; // Pin pre červenú zložku RGB LED diódy
const int rgbPinGreen = 6; // Pin pre zelenú zložku RGB LED diódy
const int rgbPinBlue = 7; // Pin pre modrú zložku RGB LED diódy
int redValue = 0;
int greenValue = 0;
int blueValue = 0;
void setup() {
pinMode(redButtonPin, INPUT_PULLUP);
pinMode(greenButtonPin, INPUT_PULLUP);
pinMode(blueButtonPin, INPUT_PULLUP);
pinMode(rgbPinRed, OUTPUT);
pinMode(rgbPinGreen, OUTPUT);
pinMode(rgbPinBlue, OUTPUT);
}
void loop() {
if (digitalRead(redButtonPin) == LOW) {
// Červené tlačidlo je stlačené
redValue = 255;
}
if (digitalRead(greenButtonPin) == LOW) {
// Zelené tlačidlo je stlačené
greenValue = 255;
}
if (digitalRead(blueButtonPin) == LOW) {
// Modré tlačidlo je stlačené
blueValue = 255;
}
// Nastav hodnoty zložiek RGB LED diódy
analogWrite(rgbPinRed, redValue);
analogWrite(rgbPinGreen, greenValue);
analogWrite(rgbPinBlue, blueValue);
// Resetuj hodnoty pre nasledujúci cyklus
redValue = 0;
greenValue = 0;
blueValue = 0;
}