i am still trying to find a way to code this
if button 1 is pressed it will ignore the command even if button 2 3 4 is press
if button 2 is press it will ignore button 3 4
if button 3 is press it will ignore button 4
meaning button 1,2,3 will overwrite button 4
And button 1,2 will over write button 3,4
button 1 will over write button 2,3,4
i only manage to code until this but i don know which command can help me complete my task
it will be best if example is provided
i am very keen on learning but i do not know where to start and what to code
int BluePin = 9;
int RedPin = 10;
int GreenPin = 11;
const int buttonPin1 = 2;
const int buttonPin2 = 3;
const int buttonPin3 = 4;
const int buttonPin4 = 5;
boolean ledState; // on or off
unsigned long ledTime; // when leds were turned on
unsigned long interval = 5000; // burn time
int red = 0;
int green = 0;
int blue = 0;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
void setColor(int red, int green, int blue)
{
analogWrite(RedPin, red);
analogWrite(GreenPin, green);
analogWrite(BluePin, blue);
}
void setup() {
Serial.begin(9600);
pinMode(BluePin, OUTPUT);
pinMode(RedPin, OUTPUT);
pinMode(GreenPin, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
}
void loop() {
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
if (buttonState1 = HIGH) {
{ setColor(0, 255, 0);
if (buttonState2 = HIGH) {
setColor(0, 255, 0);
}
{ setColor(0, 255, 0);
}
if (buttonState3 = HIGH)
{ setColor(255, 0, 0);
}
if (buttonState4 = HIGH)
{ setColor(80, 0, 80);
}
}
ledState = true; // remember led(s) are on
ledTime = millis(); // note the time
}
if (ledState && millis() - ledTime > interval) { // if a led is on and time is up
{
setColor(0, 0, 0);
ledState = false; // leds are off
};
}
}