Blog - LEDbar controller for Garbage run 2018

Atmega based LEDbar controller to switch 4 LEDbars (12v 180w) on a car for the Garbage run 2018
Updated on: 05-02-2018 :: Version 0.1

Specifications

  • Input voltage: 12~15v
  • N-channel switching (Negative)
  • Strobe function (random output selection)
  • 4x 12v 40~50a output (LEDbar, 3x front & 1x rear)
  • 6x 12v control input (all on, strobe, 10% front dim, rear signal, high beam, rear on)
  • 1x Potentiometer to change strobe frequency

  • Schematic

    LEDbar schematic

    ..

    Parts

    Part details used for the controller:

  • Arduino mini module or compatible: (link to arduino site)
  • Logic level mosfets to switch the output: IRLZ44n or IRLZ44z (choose what fits your needs)
  • Buck converter (step-down): 12~15v to 5v. QSKJ converter is used here

  • ATmega source code (Arduino IDE)

    /*
    Atmega sketch for LEDbar controller - Duteweerd Elektronica 2017 - 2018
    */
    
    int allOnPin = 2;                 //Switch: All on (Pin2)
    int strobePin = 3;                //
    int LEDBar_10frontPin = 4;        //
    int LEDBar_rearPin = 5;           //
    int LEDBar_highbeamSigPin = 7;    //
    int LEDBar_rearSigPin = 6;        //
    int LEDbarF1_outPin = 8;          //
    int LEDbarF2_outPin = 9;          //
    int LEDbarF3_outPin = 10;         //
    int LEDbarR1_outPin = 11;         //
    int HeartBeat_LEDPin = 13;        //
    int strobe_potPin = A1;           //
    
    int val_allOnPin = 0;
    int val_strobePin = 0;
    int val_LEDBar_10frontPin = 0;
    int val_LEDBar_rearPin = 0;
    int val_LEDBar_highbeamSigPin = 0;
    int val_LEDBar_rearSigPin = 0;
    int val_strobe_potPin = 0;
    int randNumber;
    
    int last_allOnPin = LOW;
    int last_strobePin = LOW;
    int last_LEDBar_10frontPin = LOW;
    int last_LEDBar_rearPin = LOW;
    int last_LEDBar_highbeamSigPin = LOW;
    int last_LEDBar_rearSigPin = LOW;
    
    void setup() {
      // initialize PINS for INPUT
      pinMode(allOnPin, INPUT);
      pinMode(strobePin, INPUT);
      pinMode(LEDBar_10frontPin, INPUT);
      pinMode(LEDBar_rearPin, INPUT);
      pinMode(LEDBar_highbeamSigPin, INPUT);
      pinMode(LEDBar_rearSigPin, INPUT);
      pinMode(strobe_potPin, INPUT);
      
      // initialize PINS for OUTPUT
      pinMode(LEDbarF1_outPin, OUTPUT);
      pinMode(LEDbarF2_outPin, OUTPUT);
      pinMode(LEDbarF3_outPin, OUTPUT);
      pinMode(LEDbarR1_outPin, OUTPUT);
      pinMode(HeartBeat_LEDPin, OUTPUT);
    }
    
    void heartbeat() {
        //Perform a heartbeat indication on LED (Buildin Pin 13)
      digitalWrite(HeartBeat_LEDPin, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(500);                             // wait for half a second
      digitalWrite(HeartBeat_LEDPin, LOW);    // turn the LED off by making the voltage LOW
      delay(1000);                            // wait for a second
    }
    
    void strobe() {
        //Strobe function code
      randNumber = random(8, 12);			  // select random output for strobe
      digitalWrite(randNumber, HIGH);
      delay(val_strobe_potPin);               // wait for however potentiometer value is
      digitalWrite(randNumber, LOW);
      delay(val_strobe_potPin);               // wait for however potentiometer value is
    }
    
    void loop() {
      // Read switch states
      val_allOnPin = digitalRead(allOnPin);
      val_strobePin = digitalRead(strobePin);
      val_LEDBar_10frontPin = digitalRead(LEDBar_10frontPin);
      val_LEDBar_rearPin = digitalRead(LEDBar_rearPin);
      val_LEDBar_highbeamSigPin = digitalRead(LEDBar_highbeamSigPin);
      val_LEDBar_rearSigPin = digitalRead(LEDBar_rearSigPin);
      val_strobe_potPin = map(analogRead (strobe_potPin), 0, 1023, 10, 1000);
      //heartbeat();      //heartbeat LED function
    
      if (val_strobePin == HIGH & last_strobePin == LOW) {
        digitalWrite(LEDbarR1_outPin, LOW);
        digitalWrite(LEDbarF1_outPin, LOW);
        digitalWrite(LEDbarF2_outPin, LOW);
        digitalWrite(LEDbarF3_outPin, LOW);
        last_strobePin = HIGH;
      }
    
      if (val_strobePin == LOW & last_strobePin == HIGH) {
        last_strobePin = LOW;
      }
      
      if (val_strobePin == HIGH) {
      //Code to start strobe function
      strobe();
      return;
      }
    
      //Rear light function
      if (val_LEDBar_rearSigPin == HIGH) {
        //code to start rear light function
        digitalWrite(LEDbarR1_outPin, HIGH);
        last_LEDBar_rearSigPin = HIGH;
      }
      if (val_LEDBar_rearSigPin == LOW & last_LEDBar_rearSigPin == HIGH) {
        digitalWrite(LEDbarR1_outPin, LOW);
        last_LEDBar_rearSigPin = LOW;
      }
    
      //Rear light function
      if (val_LEDBar_rearPin == HIGH) {
        //code to start rear light function
        digitalWrite(LEDbarR1_outPin, HIGH);
        last_LEDBar_rearPin = HIGH;
      }
      if (val_LEDBar_rearPin == LOW & last_LEDBar_rearPin == HIGH) {
        digitalWrite(LEDbarR1_outPin, LOW);
        last_LEDBar_rearPin = LOW;
      }  
    
      //High beam function
      if (val_LEDBar_highbeamSigPin == HIGH) {
        //code to start high beam function
        digitalWrite(LEDbarF1_outPin, HIGH);
        digitalWrite(LEDbarF2_outPin, HIGH);
        digitalWrite(LEDbarF3_outPin, HIGH);
        last_LEDBar_highbeamSigPin = HIGH;
      }
       
        if (val_LEDBar_highbeamSigPin == LOW & last_LEDBar_highbeamSigPin == HIGH) {
        digitalWrite(LEDbarF1_outPin, LOW);
        digitalWrite(LEDbarF2_outPin, LOW);
        digitalWrite(LEDbarF3_outPin, LOW);
        last_LEDBar_highbeamSigPin = LOW;
      }
    
      if (val_allOnPin == HIGH) {
      //Code to start allOn function
        digitalWrite(LEDbarR1_outPin, HIGH);
        digitalWrite(LEDbarF1_outPin, HIGH);
        digitalWrite(LEDbarF2_outPin, HIGH);
        digitalWrite(LEDbarF3_outPin, HIGH);
        last_allOnPin = HIGH;
      }
      
      if (val_allOnPin == LOW & last_allOnPin == HIGH) {
        digitalWrite(LEDbarR1_outPin, LOW);
        digitalWrite(LEDbarF1_outPin, LOW);
        digitalWrite(LEDbarF2_outPin, LOW);
        digitalWrite(LEDbarF3_outPin, LOW);
        last_allOnPin = LOW;
      }
    
      if (val_LEDBar_10frontPin == HIGH) {
      //Code to start allOn function
        digitalWrite(LEDbarF1_outPin, 30);
        last_LEDBar_10frontPin = HIGH;
      } 
      
      if (val_LEDBar_10frontPin == LOW & last_LEDBar_10frontPin == HIGH) {
        digitalWrite(LEDbarF1_outPin, LOW);
        last_LEDBar_10frontPin = LOW;
      }
    }
    
    		

    Finished product

    LEDbar finished 1 LEDbar finished 2

    If you have any questions about this topic, please contact me

    If this was interesting for you, please consider a donation via PayPal here