{"id":1041,"date":"2020-10-10T06:40:44","date_gmt":"2020-10-10T06:40:44","guid":{"rendered":"http:\/\/www.tech-g.com\/?p=1041"},"modified":"2023-05-16T19:26:48","modified_gmt":"2023-05-16T19:26:48","slug":"8-chan-relay-module-with-arduino-pro-mini-3-3v","status":"publish","type":"post","link":"https:\/\/www.voodoo.business\/blog\/2020\/10\/10\/8-chan-relay-module-with-arduino-pro-mini-3-3v\/","title":{"rendered":"8 Chan relay module with arduino pro mini 3.3v"},"content":{"rendered":"\n<p>To begin with, an Arduino pro mini is capable of driving the 8 port relay with optocouplers, the power required to drive the mechanical relay is provided separately with the most common relay boards on the market, this photo (And video) should demonstrate that<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.qworqs.com\/wp-content\/uploads\/2020\/10\/20201009_221930-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/www.qworqs.com\/wp-content\/uploads\/2020\/10\/20201009_221930-1024x768.jpg\" alt=\"8 channel relay module for arduino\" class=\"wp-image-1042\" srcset=\"https:\/\/www.voodoo.business\/blog\/wp-content\/uploads\/2020\/10\/20201009_221930-1024x768.jpg 1024w, https:\/\/www.voodoo.business\/blog\/wp-content\/uploads\/2020\/10\/20201009_221930-300x225.jpg 300w, https:\/\/www.voodoo.business\/blog\/wp-content\/uploads\/2020\/10\/20201009_221930-768x576.jpg 768w, https:\/\/www.voodoo.business\/blog\/wp-content\/uploads\/2020\/10\/20201009_221930-1536x1152.jpg 1536w, https:\/\/www.voodoo.business\/blog\/wp-content\/uploads\/2020\/10\/20201009_221930-2048x1536.jpg 2048w, https:\/\/www.voodoo.business\/blog\/wp-content\/uploads\/2020\/10\/20201009_221930-1200x900.jpg 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>In the photo above, the center connector is the COM (Common), the one to it&#8217;s left is the normally open, and the one to it&#8217;s right is normally closed<\/p>\n\n\n\n<p>The jumper on the JD-VCC means using the same power that is powering the board for the coil, you can replace the jumper with an external power supply that doesn&#8217;t even need to have a common ground with the arduino&#8217;s power<\/p>\n\n\n\n<p>The image above demonstrates the wiring, the power supply is a computer power supply, the relay module uses the 5V power lines from the power supply, while the Arduino uses the 3V3 line, the board&#8217;s control lines will work on logic low, hence, it will work when we are below 2V, it works perfectly fine with the 3.3V from the Arduino.<\/p>\n\n\n\n<p>here is the source code (Very simple code, just to pull the digital lines low, then high again, the delay in the engagement is just for fun.)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/\/ constants won't change. Used here to set a pin number:\nconst int ledPin =  LED_BUILTIN;\/\/ the number of the LED pin\nconst int relay1 = 2;\nconst int relay2 = 3;\nconst int relay3 = 4;\nconst int relay4 = 5;\nconst int relay5 = 6;\nconst int relay6 = 7;\nconst int relay7 = 8;\nconst int relay8 = 9;\n\n\n\n\/\/ Variables will change:\nint ledState = LOW;             \/\/ ledState used to set the LED\n\n\/\/ Generally, you should use \"unsigned long\" for variables that hold time\n\/\/ The value will quickly become too large for an int to store\nunsigned long previousMillis = 0;        \/\/ will store last time LED was updated\n\n\/\/ constants won't change:\nconst long interval = 2000;           \/\/ interval at which to blink (milliseconds)\n\nvoid setup() {\n  \/\/ set the digital pin as output:\n  pinMode(ledPin, OUTPUT);\n  pinMode(relay1, OUTPUT);\n  pinMode(relay2, OUTPUT);\n  pinMode(relay3, OUTPUT);\n  pinMode(relay4, OUTPUT);\n  pinMode(relay5, OUTPUT);\n  pinMode(relay6, OUTPUT);\n  pinMode(relay7, OUTPUT);\n  pinMode(relay8, OUTPUT);\n}\n\nvoid loop() {\n  \/\/ here is where you'd put code that needs to be running all the time.\n\n  \/\/ check to see if it's time to blink the LED; that is, if the difference\n  \/\/ between the current time and last time you blinked the LED is bigger than\n  \/\/ the interval at which you want to blink the LED.\n  unsigned long currentMillis = millis();\n\n  if (currentMillis - previousMillis &gt;= interval) {\n    \/\/ save the last time you blinked the LED\n    previousMillis = currentMillis;\n\n    \/\/ if the LED is off turn it on and vice-versa:\n    if (ledState == LOW) {\n      ledState = HIGH;\n      digitalWrite(ledPin, ledState);\n      digitalWrite(relay1, ledState);\n      delay(200);\n      digitalWrite(relay2, ledState);\n      delay(200);\n      digitalWrite(relay3, ledState);\n      delay(200);\n      digitalWrite(relay4, ledState);\n      delay(200);\n      digitalWrite(relay5, ledState);\n      delay(200);\n      digitalWrite(relay6, ledState);\n      delay(200);\n      digitalWrite(relay7, ledState);\n      delay(200);\n      digitalWrite(relay8, ledState);\n      \n      delay(400);\n      ledState = LOW;\n      digitalWrite(ledPin, ledState);\n      delay(400);\n      ledState = HIGH;\n      digitalWrite(ledPin, ledState);\n      digitalWrite(relay2, ledState);\n    } else {\n      ledState = LOW;\n      digitalWrite(ledPin, ledState);\n      digitalWrite(relay1, ledState);\n      delay(100);\n      digitalWrite(relay2, ledState);\n      delay(200);\n      digitalWrite(relay3, ledState);\n      delay(300);\n      digitalWrite(relay4, ledState);\n      delay(400);\n      digitalWrite(relay5, ledState);\n      delay(500);\n      digitalWrite(relay6, ledState);\n      delay(600);\n      digitalWrite(relay7, ledState);\n      delay(150);\n      digitalWrite(relay8, ledState);\n      delay(150);\n      ledState = HIGH;\n      digitalWrite(relay8, ledState);\n      delay(700);\n      ledState = LOW;\n      digitalWrite(relay8, ledState);\n      delay(300);\n      ledState = HIGH;\n      digitalWrite(relay8, ledState);\n      delay(700);\n      ledState = LOW;\n      digitalWrite(relay8, ledState);\n      delay(300);\n    }\n\n    \/\/ set the LED with the ledState of the variable:\n    \/\/digitalWrite(ledPin, ledState);\n  }\n} <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To begin with, an Arduino pro mini is capable of driving the 8 port relay with optocouplers, the power required to drive the mechanical relay is provided separately with the most common relay boards on the market, this photo (And video) should demonstrate that In the photo above, the center connector is the COM (Common), [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[110,89],"tags":[],"class_list":["post-1041","post","type-post","status-publish","format-standard","hentry","category-arduino","category-diy-electronics"],"_links":{"self":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/1041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/comments?post=1041"}],"version-history":[{"count":7,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/1041\/revisions"}],"predecessor-version":[{"id":2203,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/1041\/revisions\/2203"}],"wp:attachment":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/media?parent=1041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/categories?post=1041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/tags?post=1041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}