LED's connected to relays will only turn on


i built simple project arduino board. use board read analog input values rotation sensor (potentiometer), , use values determine ssr relay on module turn on. connected relays led's , project works, in 1 way. example, when turn potentiometer toward maximum, relays sequentially close, supposed to. same thing when reach maximum , dial pot. toward 0. can fidget around in middle , arduino turn on relay(s) according analog values read. part works supposed to.

the problem is, when connect led's relays, led's turn on sequentially relays turn on, dial pot. 0 toward maximum. led's not turn off dial pot. down toward 0. relays indicate being turned off on module (they each have led indicator), led's connected remain on no matter what.

the standard 5v output arduino board powering relay module, led's, , sensor. every ground common arduino gnd.

so why led's not turning off? it's beginner stuff don't know about. read somewhere when use mosfet turn on , off, should connect pull-down resistor gnd, "turn-off" work. otherwise, light or motor or whatever stay on. sound applies here?

here relay module: http://www.sainsmart.com/sainsmart-4-channel-5v-solid-state-relay-module-board-omron-ssr-avr-dsp-arduino.html

my rotation sensor (pot.): https://www.bananarobotics.com/shop/analog-rotation-sensor-v1-potentiometer?gclid=cjwkeaiak8qkbrdoqyediilq5bmsjab40a5uigmfbpivo9rwmi-ooeuwoa2zftd-h5ctmcyoawcuzbocio_w_wcb


and here code, if help:

code: [select]
//define digital pins controlling relays on module
//these pins connected relay gate pins on module
#define in1 13
#define in2 11
#define in3 10
#define in4 9

void setup(){     //make sure pins output, 5v drawn them
 pinmode(in1, output);
 pinmode(in2, output);
 pinmode(in3, output);
 pinmode(in4, output);
}

void loop(){
 float rotationvalue = analogread(a0);        //read raw sensor value
 float percentvalue = rotationvalue / 10.23;      //convert raw value 0-100

 if(percentvalue >= 0.00 && percentvalue <= 1.00){        //all relays off
  digitalwrite(in1, low);
  digitalwrite(in2, low);
  digitalwrite(in3, low);
  digitalwrite(in4, low);
 }

 else if(percentvalue > 1.00 && percentvalue <= 25.00){         //turn on relay 1
  digitalwrite(in1, high);
  digitalwrite(in2, low);
  digitalwrite(in3, low);
  digitalwrite(in4, low);
 }

 else if(percentvalue > 25.00 && percentvalue <= 50.00){      //turn on relay 1, 2 
  digitalwrite(in1, high);
  digitalwrite(in2, high);
  digitalwrite(in3, low);
  digitalwrite(in4, low);
 }
 else if(percentvalue > 50.00 && percentvalue <= 75.00){       //turn on relays 1,2,3
  digitalwrite(in1, high);
  digitalwrite(in2, high);
  digitalwrite(in3, high);
  digitalwrite(in4, low);
 }
 else if(percentvalue > 75.00){         //turn on relays
  digitalwrite(in1, high);
  digitalwrite(in2, high);
  digitalwrite(in3, high);
  digitalwrite(in4, high);
 }
}



i know, can control led's directly board without relay module, i'm going use module control several bigger things. i'm experimenting led's in place first.

solid-state relays aren't dc controlling, they're ac.
(there such things "dc ssrs", sainsmart board isn't using them.)


Arduino Forum > Using Arduino > LEDs and Multiplexing > LED's connected to relays will only turn on


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code