iMatic V2 16 Channels Relay – Ansteuerung mit Arduino

Die WLAN-fähige Relaiskarte von iMatic [Amazon Partnerlink] lässt sich wunderbar mit Arduino ansteuern. Wie das funktioniert, zeigt dir diese Anleitung. Was brauche ich? iMatic v2 16-Channel-Relaisboard [Amazon Partnerlink] Arduino IDE Arduino Uno [Amazon Partnerlink] Steuerung über Arduino Arduino verbinden Verbinde nun Ihren Arduino mit Ihrem Computer. Beim ersten Mal werden alle benötigten Treiber installiert. Ist…

Image Description

Die WLAN-fähige Relaiskarte von iMatic [Amazon Partnerlink] lässt sich wunderbar mit Arduino ansteuern. Wie das funktioniert, zeigt dir diese Anleitung.

Was brauche ich?

Steuerung über Arduino

Arduino verbinden

Verbinde nun Ihren Arduino mit Ihrem Computer. Beim ersten Mal werden alle benötigten Treiber installiert. Ist die Installation abgeschlossen können Sie die Arduino Software zur Programmierung starten.

Code-Beispiel

#General code from:
YourDuino Example: Relay Control 1.10
Handles "Relay is active-low" to assure
no relay activation from reset until
application is ready.
terry@yourduino.com

#Extended & edited by:
Andreas Reitberger
kontakt@andreas-reitberger.de
*/

/*—–( Import needed libraries )—–*/
/*—–( Declare Constants )—–*/
#define RELAY_ON 0
#define RELAY_OFF 1
/*—–( Declare objects )—–*/
/*—–( Declare Variables )—–*/
int mode = 1;
int waittimer = 250; //Waittimer between switch ON/OFF (in ms)
/*—–( Declare Pins—-*/
// Arduino Digital I/O pin number
//Relais 1-8
#define Relay_1 2
#define Relay_2 3
#define Relay_3 4
#define Relay_4 5
#define Relay_5 6
#define Relay_6 7
#define Relay_7 8
#define Relay_8 9
//Relais 9-16
/*
//Make sure your Arduino has this much Output Pins!
#define Relay_9 10
#define Relay_10 11
#define Relay_11 12
#define Relay_12 13
#define Relay_13 14
#define Relay_14 15
#define Relay_15 16
#define Relay_16 16
*/
void setup() /****** SETUP: RUNS ONCE ******/
{
//——-( Initialize Pins so relays are inactive at reset)—-
digitalWrite(Relay_1, RELAY_OFF);
digitalWrite(Relay_2, RELAY_OFF);
digitalWrite(Relay_3, RELAY_OFF);
digitalWrite(Relay_4, RELAY_OFF);
digitalWrite(Relay_5, RELAY_OFF);
digitalWrite(Relay_6, RELAY_OFF);
digitalWrite(Relay_7, RELAY_OFF);
digitalWrite(Relay_8, RELAY_OFF);

//—( THEN set pins as outputs )—-
pinMode(Relay_1, OUTPUT);
pinMode(Relay_2, OUTPUT);
pinMode(Relay_3, OUTPUT);
pinMode(Relay_4, OUTPUT);
pinMode(Relay_5, OUTPUT);
pinMode(Relay_6, OUTPUT);
pinMode(Relay_7, OUTPUT);
pinMode(Relay_8, OUTPUT);
delay(4000); //Check that all relays are inactive at Reset

}//–(end setup )—

void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
/*Mode 1
Light effect for the roof LED'S
*/
do{
//—( Turn all 8 relays ON in sequence)—
//LED-Stripe 01
digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
delay(waittimer); // wait for a second
digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF
//LED-Stripe 02
digitalWrite(Relay_2, RELAY_ON);// set the Relay ON
delay(waittimer); // wait for a second
digitalWrite(Relay_2, RELAY_OFF);// set the Relay OFF
//LED-Stripe 03
digitalWrite(Relay_3, RELAY_ON);// set the Relay ON
delay(waittimer); // wait for a second
digitalWrite(Relay_3, RELAY_OFF);// set the Relay OFF
//LED-Stripe 04
digitalWrite(Relay_4, RELAY_ON);// set the Relay ON
delay(waittimer);
digitalWrite(Relay_4, RELAY_OFF);// set the Relay OFF
//LED-Stripe 05
digitalWrite(Relay_5, RELAY_ON);// set the Relay ON
delay(waittimer); // wait for a second
digitalWrite(Relay_5, RELAY_OFF);// set the Relay OFF
//LED-Stripe 06
digitalWrite(Relay_6, RELAY_ON);// set the Relay ON
delay(waittimer); // wait for a second
digitalWrite(Relay_6, RELAY_OFF);// set the Relay OFF
//LED-Stripe 07
digitalWrite(Relay_7, RELAY_ON);// set the Relay ON
delay(waittimer); // wait for a second
digitalWrite(Relay_7, RELAY_OFF);// set the Relay OFF
//LED-Stripe 08
digitalWrite(Relay_8, RELAY_ON);// set the Relay ON
delay(waittimer);
digitalWrite(Relay_8, RELAY_OFF);// set the Relay OFF
delay(4000); // wait see all relays ON

for (int i = 1; i <= 5; i++)
{
//—( Turn all 8 relays OFF in sequence)—
digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF
digitalWrite(Relay_2, RELAY_OFF);// set the Relay OFF
digitalWrite(Relay_3, RELAY_OFF);// set the Relay OFF
digitalWrite(Relay_4, RELAY_OFF);// set the Relay OFF
digitalWrite(Relay_5, RELAY_OFF);// set the Relay OFF
digitalWrite(Relay_6, RELAY_OFF);// set the Relay OFF
digitalWrite(Relay_7, RELAY_OFF);// set the Relay OFF
digitalWrite(Relay_8, RELAY_OFF);// set the Relay OFF
delay(waittimer*2); // wait see all relays OFF
//—( Turn all 8 relays ON in sequence)—
digitalWrite(Relay_1, RELAY_ON);// set the Relay OFF
digitalWrite(Relay_2, RELAY_ON);// set the Relay OFF
digitalWrite(Relay_3, RELAY_ON);// set the Relay OFF
digitalWrite(Relay_4, RELAY_ON);// set the Relay OFF
digitalWrite(Relay_5, RELAY_ON);// set the Relay OFF
digitalWrite(Relay_6, RELAY_ON);// set the Relay OFF
digitalWrite(Relay_7, RELAY_ON);// set the Relay OFF
digitalWrite(Relay_8, RELAY_ON);// set the Relay OFF
delay(waittimer*2); // wait see all relays OFF
}
}
while (mode == 1);

//—( Turn all 8 relays ON in sequence)—
digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
delay(1000); // wait for a second
digitalWrite(Relay_2, RELAY_ON);// set the Relay ON
delay(1000); // wait for a second
digitalWrite(Relay_3, RELAY_ON);// set the Relay ON
delay(1000); // wait for a second
digitalWrite(Relay_4, RELAY_ON);// set the Relay ON
delay(1000);
digitalWrite(Relay_5, RELAY_ON);// set the Relay ON
delay(1000); // wait for a second
digitalWrite(Relay_6, RELAY_ON);// set the Relay ON
delay(1000); // wait for a second
digitalWrite(Relay_7, RELAY_ON);// set the Relay ON
delay(1000); // wait for a second
digitalWrite(Relay_8, RELAY_ON);// set the Relay ON
delay(4000); // wait see all relays ON

//—( Turn all 8 relays OFF in sequence)—
digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF
delay(1000); // wait for a second
digitalWrite(Relay_2, RELAY_OFF);// set the Relay OFF
delay(1000); // wait for a second
digitalWrite(Relay_3, RELAY_OFF);// set the Relay OFF
delay(1000); // wait for a second
digitalWrite(Relay_4, RELAY_OFF);// set the Relay OFF
delay(1000);
digitalWrite(Relay_5, RELAY_OFF);// set the Relay OFF
delay(1000); // wait for a second
digitalWrite(Relay_6, RELAY_OFF);// set the Relay OFF
delay(1000); // wait for a second
digitalWrite(Relay_7, RELAY_OFF);// set the Relay OFF
delay(1000); // wait for a second
digitalWrite(Relay_8, RELAY_OFF);// set the Relay OFF
delay(4000); // wait see all relays OFF

}//–(end main loop )—

//*********( THE END )***********

War dieser Artikel hilfreich für Sie?

Ja Nein

Verwandte Artikel