(Originally posted on the Savage///Circuits Forums December 27th, 2014, 06:04 PM by zappman)
Test of a Sain Smart 8 Relay Module Board part number 20-018-102 (ignore all the technical information here its wrong) with an Arduino Uno Board.
Link to part at Microcenter where I purchased the board for $11.99
To learn how to use this board, and how it works go to this link; http://arduino-info.wikispaces.com/ArduinoPower
*** Warning: Make sure you understand the correct operation of the Pins labeled "GND VCC JD-VCC" or you will damage your micro-controller board ***



https://youtu.be/Yjw9HMGydHI
The Test Code
Code: Select all
/*
Test Program B Rev001 for the Sainsmart "5V 8-Channel Relay interface board" 20-018-102
Night Rider Chase Sequence Demo
This example code is in the public domain.
2014_12_13
by M. Sapp
*/
const int NbrRLYs = 8;
const int rlyPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
const int wait = 30; // 1000 = wait for a second
// this setup function runs once when you press reset or power the board
void setup(){
//When the baords power on or are reset, we want to ensure all relays are NOT energized
// To turn the Relays & LEDs off, a Logic High is needed on each input pin to the relay board
// Set the pins to Logic Highs
for (int rly = 0; rly < NbrRLYs; rly++)
{
digitalWrite(rlyPins[rly],HIGH); //relay IN8, Right most thru relay IN0, Left most
pinMode(rlyPins[rly],OUTPUT); //relay IN8, Right most thru relay IN0, Left most // initialize digital pins as an outputs.
}
}
// this loop function runs over and over again forever
void loop() {
for (int rly = 0; rly < NbrRLYs-1; rly++)
{
digitalWrite(rlyPins[rly], LOW);
delay(wait);
digitalWrite(rlyPins[rly+1], LOW);
delay(wait);
digitalWrite(rlyPins[rly], HIGH);
delay(wait*2);
}
for (int rly = NbrRLYs-1; rly > 0; rly--){
digitalWrite(rlyPins[rly], LOW);
delay(wait);
digitalWrite(rlyPins[rly-1], LOW);
delay(wait);
digitalWrite(rlyPins[rly], HIGH);
delay(wait*2);
}
}