// Relay channels
const int relayChannels[7] = {6, 7, 8, 9, 10, 11, 12}; // Assuming these pins
// Analog input pins for buttons
const int buttonTurnSignal1 = A0; // Use the appropriate analog pin
const int buttonTurnSignal2 = A1; // Use the appropriate analog pin
const int buttonBrake = A2; // Use the appropriate analog pin
const int buttonLowBeam = A3; // Use the appropriate analog pin
const int buttonHighBeam = A4; // Use the appropriate analog pin
void setup() {
// Initialize relay channels as OUTPUTs
for (int i = 0; i < 7; i++) {
pinMode(relayChannels[i], OUTPUT);
digitalWrite(relayChannels[i], HIGH); // Initialize in OFF state (assuming active LOW relays)
}
// Initialize input pins
pinMode(buttonTurnSignal1, INPUT); // No need for pull-up resistor
pinMode(buttonTurnSignal2, INPUT);
pinMode(buttonBrake, INPUT);
pinMode(buttonLowBeam, INPUT);
pinMode(buttonHighBeam, INPUT);
}
void loop() {
// Turn Signal Logic using buttons
if (analogRead(buttonTurnSignal1) < 100) { // Adjust the threshold based on your button behavior
digitalWrite(relayChannels[0], LOW); // ON
digitalWrite(relayChannels[2], LOW); // ON
delay(500);
digitalWrite(relayChannels[0], HIGH); // OFF
digitalWrite(relayChannels[2], HIGH); // OFF
delay(500);
}
if (analogRead(buttonTurnSignal2) < 100) { // Adjust the threshold based on your button behavior
digitalWrite(relayChannels[1], LOW); // ON
digitalWrite(relayChannels[3], LOW); // ON
delay(500);
digitalWrite(relayChannels[1], HIGH); // OFF
digitalWrite(relayChannels[3], HIGH); // OFF
delay(500);
}
// Brake Light Logic using button
if (analogRead(buttonBrake) < 100) { // Adjust the threshold based on your button behavior
digitalWrite(relayChannels[4], LOW); // ON
} else {
digitalWrite(relayChannels[4], HIGH); // OFF
}
// Low Beam Logic using button
if (analogRead(buttonLowBeam) < 100) { // Adjust the threshold based on your button behavior
digitalWrite(relayChannels[5], LOW); // ON
} else {
digitalWrite(relayChannels[5], HIGH); // OFF
}
// High Beam Logic using button
if (analogRead(buttonHighBeam) < 100) { // Adjust the threshold based on your button behavior
digitalWrite(relayChannels[6], LOW); // ON
} else {
digitalWrite(relayChannels[6], HIGH); // OFF
}
}