#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
int buttonOpen = 2; // Pin del pulsante di apertura
int buttonClose = 3; // Pin del pulsante di chiusura
int buttonStop = 4; // Pin del pulsante di stop
void setup() {
Serial.begin(9600);
mySwitch.enableTransmit(10); // Pin D10 per trasmettere
// Abilita le resistenze di pull-up interne
pinMode(buttonOpen, INPUT_PULLUP); // Pulsante apertura
pinMode(buttonClose, INPUT_PULLUP); // Pulsante chiusura
pinMode(buttonStop, INPUT_PULLUP); // Pulsante stop
}
void loop() {
// Se il pulsante di apertura è premuto (LOW)
if (digitalRead(buttonOpen) == LOW) {
mySwitch.send(111111, 24); // Invia codice apertura (24 bit)
delay(100); // Pausa per evitare ripetizioni troppo veloci
}
// Se il pulsante di chiusura è premuto (LOW)
if (digitalRead(buttonClose) == LOW) {
mySwitch.send(222222, 24); // Invia codice chiusura (24 bit)
delay(100);
}
// Se il pulsante di stop è premuto (LOW)
if (digitalRead(buttonStop) == LOW) {
mySwitch.send(333333, 24); // Invia codice stop (24 bit)
delay(100);
}
} |