iMatic V2 16 Channels Relay – Steuerung mit Arduino Uno R3

iMatic

Hier zeige ich euch, wie Ihr das iMatic Relais Board auch mit einem Arduino ansteuern könnt. Ich habe dafür den Arduino UNO R3 gewählt, da ich so einen noch rumliegen hatte. Um jedoch alle 16 Relais einzeln ansteuern zu können, würde ich den

Durch das Klicken auf das oben abgebildete Produkt gelangt Ihr über einen Amazon Partnerlink auf die gewünschte Produktseite. Durch den Kauf über unserer Partnerlink erhalten wir eine kleine Provision von Amazon für die Vermittlung. Mehr über das Amazon Partnerprogramm können Sie unter Punkt 8 (Amazon Partnerprogramm) in unserer Datenschutzerklärung nachlesen.

Die Anleitung

Der Code

Sollten Sie das erste mal mit Arduino arbeiten, so laden Sie sich bitte die aktuellste Software herunter.

arduino.cc

Arduino verbinden

Verbinden Sie 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.

/*
#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
Homepage
kontakt@wdbase.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 )***********

0

0

Back To Top

Was this article helpful?

Related Articles

Leave A Comment?

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.