Solid state relay turning on issue

Hi everyone,
I’m using an Arudnio Uno and I’m programming it to control a stepper motor and a solid state relay.
The code is fairly simple.
If i feed a bunch of character in the serial monitors, it does a specific action as you can see from the code.
However, say for example I keep the relay off, and send a signal to make the motor move, the relay somehow turns on.

// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!

#include <AFMotor.h>
char v;
AF_Stepper motor(200, 1);

void setup() {
  Serial.begin(9600);      // set up Serial library at 9600 bps
  Serial.println("Stepper test!");
  pinMode(8,OUTPUT);//Connecting to the relay
  motor.setSpeed(20);  // 20 rpm   
}

void loop() {  
  if (Serial.available()>0)
  {
    delay(50);
    v=Serial.read();
    if(v=='H'){
     motor.step(50, FORWARD, MICROSTEP);
     Serial.println("FORWARD");
     delay(1000);
    }
    if(v=='L')
    {
      motor.step(50, BACKWARD,MICROSTEP);
      Serial.println("BACKWARD");
      delay(1000);
      
      
    }
    if(v=='A')
    {
      motor.step(100, BACKWARD,DOUBLE);
      Serial.println("BACKWARD");
      delay(1000);
    }
    if(v=='B')
    {
      motor.step(100, BACKWARD,DOUBLE);
      Serial.println("BACKWARD");
      delay(1000);
    }
    if (v=='Y')
    {
      digitalWrite(8,HIGH);//turns relay on
      delay(200);
    }
    if (v=='Z')
    {
      digitalWrite(8,LOW);//turns relay off
      delay(200);
    }
    else
    {
      Serial.println("WRONG INPUT");
       
      
    }
    
  }
  
}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Can you post a link to the spec/data of the SSR please?

Thanks.. Tom... :slight_smile:

Yes, definitely post your code properly if you want people to respond.

Hi,
Here’s the link to specs of the relay : https://www.ghielectronics.com/downloads/man/20084141716341001RelayX1.pdf

Also,
I apologize for not mentioning this earlier. I have mounted a Motor Shield v1.2 on the Arduino as well. The Arduino is powered by 9V AC adapter. I have attached a basic drawing of my circuit. I’m new here so kindly let me know if I anything I said doesn’t make sense.

Hi,
Is pin8 used by the motor shield,

Please check the schematic of the board, you should be able to get a copy from the site/page you purchased the shield.

Tom.... :slight_smile:

You may have power issues ... the Arduino (powered by 9V) may not have enough current available @5V to drive and power the relay. What are you using to power the Motor Shield? Showing us your circuit c/w power connections would be very helpful (as suggested by TomGeorge) ... or at least let us know the ratings of your power source(s).

Thanks ... dl

Hi,
Is this your motor shield?


If you look you cab see a PCB track coming from pin8 to the shield components, so it looks like pin8 is used for a motor control function.

Tom.... :slight_smile:

Hi again,
Found the schematic, pin8 is part of the serial comms.
mshieldv12schem.png

Tom… :slight_smile: