Using 5v SSr module to control mototrcycle horn

Good evening all, I’m working on a control panel for my 2001 Honda rebel. I want to use a SSR to control the horn on the bike but I don’t want to disable the button on the bike. I connected to light green wire to the DC+ and the black wire (ground) to the DC-. I have a jumper wire connected to pin 10 on my Arduino mega and connected to channel 1. In my code I have the pinMode set to HIGH. So when the program runs through the "if statement and returns a true value the digitalWrite is set to LOW. My code compiles but the horn is not turning on when the statement is true. I think I may have it wired incorrectly. Any ideas would be appreciated. Ive attached a copy of the wiring diagram for my Honda rebel
Thanks

Due to lack of focus, the circuit is difficult to read.

The relay output should effectively be across the horn switch.

Give us a hand drawn circuit and photographed. Also supply the code in code tags (</> icon).

Weedpharma

Ok here is my code. and i attached a hand drawn diagram

//Senior Design Control Panel Source Code
#include <TinyGPS.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <Wire.h>
#include <EEPROM.h>
#include <SPI.h>
#include <GD2.h>
 

//Define Pins
#define trigPin1    45
#define echoPin1    47
#define trigPin2    41
#define echoPin2    43

#define leftLED     5
#define rightLED    6
#define hornPin     26
#define TempSensor  37

//Display definitions
#define MOCK        0
#define LOGO_W      238   // Logo width in pixels
#define LOGO_H      137   // Logo height in pixels
#define LOGO_HOLD   1000  // Logo hold time in ms
#define BIKE_W      259
#define BIKE_H      182

//Initialize gps
TinyGPS gps;

//Temp Sensor Initialize
OneWire oneWire(TempSensor);
DallasTemperature Sensors (&oneWire);
//Global variables
float flat, flon, fmph;
unsigned long fix_age;
bool alarmDisable = true;

 //static bool feedgps();
 //static void gpsdump(TinyGPS &gps);
 //void driveMode();
// returns distance in mm
int distance(int trigPin, int echoPin)
{
  digitalWrite(trigPin, LOW);
  delay(100);
  digitalWrite(trigPin, HIGH);
  delay(100);
  digitalWrite(trigPin, LOW);
#if MOCK
  long dur = 1000;
#else
  long dur = pulseIn(echoPin, HIGH);
#endif
  // 2.93 microsecond per millimeter
  // dur is round-trip so divide by 2
  return 100 * dur / (2 * 293);
}

// Rescale x from the range (x0, x1) to the range (y0, y1)
int rescale(int x, int x0, int x1, int y0, int y1)
{
  x = max(x0, min(x1, x));
  return y0 + ((x - x0) * long(y1 - y0) / float(x1 - x0));
}


void setup() {
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);
 //Turn off alarm
 pinMode(leftLED, OUTPUT);
 digitalWrite(leftLED, HIGH);  
 pinMode(rightLED, OUTPUT);
 digitalWrite(rightLED, HIGH);
 pinMode(hornPin, OUTPUT);
 digitalWrite(hornPin, HIGH);
 //Start SPI devices
     Sensors.begin();
     Serial1.begin(9600);
     Serial.begin(38400);
  GD.begin();
  GD.BitmapHandle(0);
  GD.cmd_loadimage(0, 0);
  GD.load("logo.jpg");

  GD.BitmapHandle(1);
  GD.cmd_loadimage(-1, 0);
  GD.load("bikeview.jpg");

  GD.ClearColorRGB(0xffffff);
  GD.Clear();
  GD.Begin(BITMAPS);
  GD.Vertex2ii((480 - LOGO_W) / 2, (272 - LOGO_H) / 2);
  GD.swap();

  delay(LOGO_HOLD);
 
}

// red < 1000 mm
// yel 1000-2000 mm
// grn >2000 ,,

void zones(int lr, int r)
{
  int zw = (480 - BIKE_W) / 2;
  int zh = 100;
  byte z = min(r / 1000, 2);
  static const uint32_t c[] = {0xff0000, 0xffff00, 0x00ff00};

  int y = 136;
  if (lr == 0)
    GD.ScissorXY(0, (272 - zh) / 2);
  else
    GD.ScissorXY(480 - zw, (272 - zh) / 2);
  GD.ScissorSize(zw, zh);
  GD.Begin(POINTS);
  GD.ColorRGB(c[z]);
  int r2 = rescale(r, 800, 2000, 160 << 4, 235 << 4);
  GD.PointSize(r2);
  GD.Vertex2ii(240, y);
  GD.ColorRGB(0xffffff);
  GD.PointSize(138 << 4);
  GD.Vertex2ii(240, y);
  GD.RestoreContext();
}


void loop() {

  GD.ClearColorRGB(0xffffff);
  GD.Clear();
  GD.Begin(BITMAPS);
  GD.Vertex2ii((480 - BIKE_W) / 2, (272 - BIKE_H), 1);

  //Parse GPS data?
  
bool newdata = false;
  unsigned long start = millis();
  
//   Every 100ms we print an update
  while (millis() - start < 100)
  {
    if (feedgps())
      newdata = true;
  }
  gpsdump(gps);

  
// Check Mode
driveMode(fmph);  

//Display ultrasonic waves
  int Lmm = distance(trigPin1, echoPin1);
  int Rmm = distance(trigPin2, echoPin2);
  //GD.ColorRGB(0x000000);
  //GD.cmd_number(       60, 272 - 50, 31, OPT_CENTERX, Lmm);
  //GD.cmd_number(480 - 60, 272 - 50, 31, OPT_CENTERX, Rmm);
  
  zones(0, Lmm);
  zones(1, Rmm);

  
Sensors.requestTemperatures();
GD.ColorRGB(0x000000);
GD.cmd_text(418, 0, 28, OPT_CENTERX, "Temperature");
GD.cmd_text( 470, 40, 28, OPT_CENTERX, "F");
GD.cmd_number( 440, 40, 28, OPT_SIGNED, Sensors.getTempFByIndex(0)); 


if (Lmm < 1500 && fmph > 5.00)
  {
  digitalWrite (leftLED,LOW); // light on
}  else 
  {digitalWrite (leftLED,HIGH);
}
if (Rmm < 1500 && fmph >  5.00)
{
  digitalWrite(rightLED,LOW);
}
else 
{
  digitalWrite(rightLED,HIGH); //light off
}
if (((Lmm < 1000) || (Rmm < 1000)) && (fmph < 5.00))   // set for debugging
{
  digitalWrite (hornPin, LOW);  // turn horn on
}
else 
{
  digitalWrite(hornPin, HIGH); // horn off
}
  GD.swap();
  GD.finish();
  
}


static bool feedgps()
{
  while (Serial1.available())
  {
    if (gps.encode(Serial1.read()))
      return true;
  }
  return false;
}

 static void gpsdump(TinyGPS &gps)
{
   gps.f_get_position(&flat, &flon, &fix_age);
   fmph = gps.f_speed_mph(); 
  char buf[100];
  dtostrf( flat,8,2,buf);
  GD.ColorRGB(0x000000);
  GD.cmd_text( 5, 0, 28, OPT_SIGNED, buf);
   dtostrf( flon,8,2,buf);
  GD.ColorRGB(0x000000);
  GD.cmd_text( 5, 25, 28, OPT_SIGNED, buf);
  dtostrf( fmph,8,2,buf);
  GD.ColorRGB(0x000000);
  GD.cmd_text( 195, 100, 28, OPT_SIGNED, buf);
  feedgps();
}

  void driveMode(float fmph) 
 {
  if (fmph == 5.00) // set for debugging 
  {
  pinMode (trigPin1, LOW);
  pinMode (trigPin2, LOW);
  pinMode (hornPin, HIGH);
  GD.ColorRGB(0x000000);
  GD.cmd_text(239, 75, 28, OPT_CENTERX, "Proximity Sensors Disabled");
 }

 }

It appears to me you have the SSR across the horn rather than across the horn switch. All you appear to be doing is short circuiting the horn.

Weedpharma

So how should I wire the relay?

Refer to #1 where I told you to wire the relay ACROSS the HORN SWITCH.

Weedpharma

I connected a wire from the NO port of the relay to the blk wire connected to the switch. The DC+ and DC- are connected to 5v on the arduino and ground on the arduino. Communications pin is to 10. Im still not getting anything? Could you explain again please?

int relayswitch = 10;
void setup() {
  pinMode(relayswitch, OUTPUT);
  digitalWrite(relayswitch, HIGH);
  // put your setup code here, to run once:

}

void loop() {
  digitalWrite(relayswitch, LOW);
  delay(4000);
  digitalWrite(relayswitch,HIGH );
}

The wires to the horn switch in your diagram are black and lt green. When you press the switch these two wire are joined and current flows from the battery via the black wire, through the switch to the lt green wire and through the horn to Gnd.

Your relay needs to be connected to replicate the function of the switch so it needs to be connected between the black wire and lt green wire. This may not be the easiest pace to connect to so find a place where you can attach to the battery for one side of the relay and connect the other side to where the lt green wire connects to the horn.

Make sure the SSR has high enough current rating as the horn will use a lot of current.

Weedpharma