ciao, se ho capito bene il tuo problema questo è il codice che ti serve:
const int button1 = 2;
const int button2 = 3;
const int out1 = 10;
const int out2 = 11;
int stateButton1 = 0;
int stateButton2 = 0;
boolean stateout1 = false;
boolean stateout2 = false;
void setup() {
pinMode(out1, OUTPUT);
pinMode(out2, OUTPUT);
pinMode(button1, INPUT);
pinMode(button2, INPUT);
}
void loop(){
stateButton1 = digitalRead(button1);
stateButton2 = digitalRead(button2);
if (stateButton1 == HIGH) {
if(stateout1 == false) {
digitalWrite(out1, HIGH);
stateout1 = true;
}
else {
digitalWrite(out1, LOW);
stateout1 = false;
}
}
if (stateButton2 == HIGH) {
if(stateout2 == false) {
digitalWrite(out2, HIGH);
stateout2 = true;
}
else {
digitalWrite(out2, LOW);
stateout2 = false;
}
}
}
sinceramente l'ho scritto al volo e non posso testarlo ma dovrebbe essere corretto (anche se sicuramente qualcuno più bravo di me può riassumerlo un pò), se hai bisogno te lo commento, ma non mi pare difficile
spero di esserti stato di aiuto.
Simone