Hey all. I have one project that I am working on currently. My previous post has been put on the back burner for now.
However I am stuck. It may seem to be an easy project for some but i have been pulling hair out trying to get this to work.
I need to control 6 relays.
Components used:
Arduino Nano
12v 8 channel solid state relay (High Trigger)
2 of micro (Limit) Switches (Gear Up and Gear down)
1 of 12mm momentary switch. (Coil Cut)
The problem im having is getting the relays to trigger how I need. Basically I am using 4 relays to control the auto trans (Shift solenoids 1&2, Trans lock up and a clutch pack. All run) and 2 to trigger the ignition coils for "flat shift"
The prompt I used for Chat GPT is:
***PinOut
D2 - SS1R (Shift solenoid 1)
D3 - SS2R (Shift Solenoid 2)
D4 - FCSR (Forward clutch solenoid)
D5 - LUSR (Lock up solenoid)
D7 - GUS (Gear Up) (Configure that pin as a digital input with pull up enabled)
D8 - GDS (Gear Down) (Configure that pin as a digital input with pull up enabled)
D11- 4 neopixel bar
D13 - ICRS (coilcut switch) (Configure that pin as a digital input with pull up enabled)
A2 - 1&4 Coil relay
A3 - 2&3 Coil relay
Relay layout
G1
D2 - High
D3 - High
D4 - High
D5 - Low
A2 LOW for 125ms
A3 LOW for 125ms
Neopixel - 1 purple
G2
D2 - High
D3 - low
D4 - High
D5 - Low
A2 LOW for 125ms
A3 LOW for 125ms
Neopixel - 2 purple
G3
D2 - low
D3 - low
D4 - High
D5 - High
A2 LOW for 125ms
A3 LOW for 125ms
Neopixel - 3 purple
G4
D2 - low
D3 - High
D4 - low
D5 - High
A2 LOW for 125ms
A3 LOW for 125ms
Neopixel - 4 purple
When arduino is powered on trigger a2 and a3 HIGH and start at G1
When arduino has triggered G1 and D7 is triggered Low, transition necessary pins to G2.
When arduino has triggered G2 and D7 is triggered Low, transition necessary pins to G3.
When arduino has triggered G3 and D7 is triggered Low, transition necessary pins to G4.
When arduino has triggered G4 and D8 is triggered Low, transition necessary pins to G3.
When arduino has triggered G3 and D8 is triggered Low, transition necessary pins to G2.
When arduino has triggered G2 and D8 is triggered Low, transition necessary pins to G1.
If d13 is triggered LOW trigger, Trigger a2 and a3 Low while D13 is LOW. ***
and the code i got is as follows
#include <Adafruit_NeoPixel.h>
#define NEOPIXEL_PIN 11
#define NUM_PIXELS 4
// Pin Definitions
const int SS1R = 2;
const int SS2R = 3;
const int FCSR = 4;
const int LUSR = 5;
const int GUS = 7;
const int GDS = 8;
const int ICRS = 13;
const int COIL1_4 = A2;
const int COIL2_3 = A3;
Adafruit_NeoPixel strip(NUM_PIXELS, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pinMode(SS1R, OUTPUT);
pinMode(SS2R, OUTPUT);
pinMode(FCSR, OUTPUT);
pinMode(LUSR, OUTPUT);
pinMode(GUS, INPUT_PULLUP);
pinMode(GDS, INPUT_PULLUP);
pinMode(ICRS, INPUT_PULLUP);
pinMode(COIL1_4, OUTPUT);
pinMode(COIL2_3, OUTPUT);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
// Start at G1
triggerG1();
}
void loop() {
if (digitalRead(GUS) == LOW) {
transitionToNextState();
}
if (digitalRead(ICRS) == LOW) {
digitalWrite(COIL1_4, LOW);
digitalWrite(COIL2_3, LOW);
}
}
void triggerG1() {
digitalWrite(SS1R, HIGH);
digitalWrite(SS2R, HIGH);
digitalWrite(FCSR, HIGH);
digitalWrite(LUSR, LOW);
digitalWrite(COIL1_4, LOW);
digitalWrite(COIL2_3, LOW);
setNeopixelColor(1);
delay(125);
}
void triggerG2() {
digitalWrite(SS1R, HIGH);
digitalWrite(SS2R, LOW);
digitalWrite(FCSR, HIGH);
digitalWrite(LUSR, LOW);
digitalWrite(COIL1_4, LOW);
digitalWrite(COIL2_3, LOW);
setNeopixelColor(2);
delay(125);
}
void triggerG3() {
digitalWrite(SS1R, LOW);
digitalWrite(SS2R, LOW);
digitalWrite(FCSR, HIGH);
digitalWrite(LUSR, HIGH);
digitalWrite(COIL1_4, LOW);
digitalWrite(COIL2_3, LOW);
setNeopixelColor(3);
delay(125);
}
void triggerG4() {
digitalWrite(SS1R, LOW);
digitalWrite(SS2R, HIGH);
digitalWrite(FCSR, LOW);
digitalWrite(LUSR, HIGH);
digitalWrite(COIL1_4, LOW);
digitalWrite(COIL2_3, LOW);
setNeopixelColor(4);
delay(125);
}
void transitionToNextState() {
static int currentState = 1;
switch (currentState) {
case 1:
triggerG1();
currentState = 2;
break;
case 2:
triggerG2();
currentState = 3;
break;
case 3:
triggerG3();
currentState = 4;
break;
case 4:
triggerG4();
currentState = 3; // Loop back to G3
break;
}
}
void setNeopixelColor(int index) {
for (int i = 0; i < NUM_PIXELS; i++) {
if (i == index - 1) {
strip.setPixelColor(i, strip.Color(128, 0, 128)); // Purple
} else {
strip.setPixelColor(i, strip.Color(0, 0, 0)); // Off
}
}
strip.show();
}
I have added everything to wowki and i am unable to get it to work. Can anyone please shed some light or modify the code so i can upload it and stop pulling out my hair. More than happy to answer any questions.
Regards
Nick.