Hi
I have been desperatly trying to write a code that i felt would be simple but i am unable to finish it.
I want to control the VMA05 relays with individual buttons in a toggle fashion with momentane pushbuttons. Six relays and six buttons. i also want a specific behavior of several RGB lights to indicate open or closed relay by switching from green to blue when activated and back when deactivated by a second press.
i have been trying several variants of code just stumbling around but i want the setup to be closely like this (in assumed function) I apreachiate any and all help, a dream would be if someone really smart could fix this code for me. The arduino board will be used to control systems for a vehicle used in Swedish volonteer mountain rescue situations as well as other live scenarios (which due to the lack of budget explains the use of arduino)
Thanks
const int BTN1 =7;
int press1 =0;
const int BTN2 = 6;
int press2 =0;
const int BTN3 = 5;
int press3 =0;
const int BTN4 = 4;
int press4 =0;
const int BTN5 = 3;
int press5 =0;
const int BTN6 = 2;
int press6 =0;
int relay1 =8;
int relay2 =9;
int relay3 =10;
int relay4 =11;
int relay5 =12;
int relay6 =13;
void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(7, INPUT);
pinMode(6, INPUT);
pinMode(5, INPUT);
pinMode(4, INPUT);
pinMode(3, INPUT);
pinMode(2, INPUT);
}
void loop()
{
press1 = digitalRead(BTN1);
if (press1 == HIGH && relay1 == LOW )
{
(relay1, HIGH);
}else
{
(relay1, LOW);
}
{
press2 = digitalRead(BTN2);
if (press2 == HIGH && relay2 == LOW )
{
(relay2, HIGH);
}else
{
(relay2, LOW);
}
{
press3 = digitalRead(BTN3);
if (press3 == HIGH && relay3 == LOW )
{
(relay3, HIGH);
}else
{
(relay3, LOW);
}
{
press4 = digitalRead(BTN4);
if (press4 == HIGH && relay4 == LOW )
{
(relay4, HIGH);
}else
{
(relay4, LOW);
}
{
press5 = digitalRead(BTN5);
if (press5 == HIGH && relay5 == LOW )
{
(relay5, HIGH);
}else
{
(relay5, LOW);
}
{
press6 = digitalRead(BTN6);
if (press6 == HIGH && relay6 == LOW )
{
(relay6, HIGH);
}else
{
(relay6, LOW);
}
}
}
}
}
}
}