DDC
  • Welcome
    • Introduction
    • Supported hardware
  • 1: Project planning
    • Switch inputs
      • Switch table
      • Direct
      • Shift register
      • Port expander
    • Analog inputs
      • External ADC
    • RGB LED
    • Digital outputs
    • PWM / Circuit control
    • EEPROM
    • Processing and memory
  • 2. Wiring
    • Switch inputs
      • Matrix
      • Direct
      • Shift register
      • Port expander
    • Analog
      • Analog switches
      • External ADC
    • RGB LED
    • Digital outputs
    • PWM / Circuit control
    • EEPROM
  • 3. Coding
    • Essentials
      • 02_Board.ino
      • 08_Joystick
      • 10_TableAndAnalog.ino
        • Switch table
        • Analog channels
      • 30_Switches.ino
    • Peripherals
      • RGB LED
        • Firmware control
          • LED functions
          • Color
          • Brightness
          • Presets
        • SimHub control
      • Digital outputs
        • Setup
        • SimHub control
        • Firmware control
      • PWM / Circuit control
        • Setup
        • Calibrate
        • Switch control
        • Trigger control
      • Shift register
      • I2C devices
        • ADS1115
        • PCA9555
        • CAT24C512
    • Advanced
      • Analog inject
      • Conditional coding
        • Triggers
        • Editors
      • Field placement
      • Presets
        • 31_RunningPresets.ino
        • 32_Presets.ino
        • Example
    • Upload
    • Naming the controller
  • 4. Connect to SimHub
    • LED control
    • Controller settings and properties
      • How to connect?
      • How does it work?
      • How to control it?
      • Property list
  • Switch library
    • Pushbutton
    • Function switches
    • Toggle switches
    • Hat switches
    • Car control functions
      • QuickSwitch
      • BrakeMagic
      • ThrottleHold
      • Handbrake
    • Pedals & paddles
      • Brake/throttle
      • Clutch
      • Bite point & launch
      • Filtered curves
      • Shifter
    • Funky switch
      • Directional
      • Center push
    • Encoders
      • rotary2Bit
      • rotary4Bit
      • funkyRotary
      • wildEncoder
      • E18
      • rotaryPulse
      • PEC11
    • Rotary switches
      • rotaryAnalog
      • quickRotary
      • SW1
      • Editing functions
    • Multiswitch complexes
      • Hybrid rotary
      • Multifunction rotary
      • Modded encoder
      • Stacked encoder
    • Preset
    • DDS
    • RGB LED control
    • PWM / Circuit control
    • Utility
  • Fast DDC
    • Buttons and LED
    • 4 encoders, buttons and LED
    • Dual clutches, 4 encoders, buttons and LED
    • Dual clutches, 6 encoders, button matrix and LED
  • CB1
    • Ordering
      • Order together
      • Order yourself
        • 1. Open in EasyEDA
        • 2. Export files
        • 3. Edit Pick&Place
        • 4. Pin headers and jumper
        • 5. Order from JLCPCB
    • Wiring
    • Code
      • Essentials
      • Complete project
      • Settings
    • Circuit
    • Shields
      • Robin
  • Collaboration
Powered by GitBook
On this page
  1. 3. Coding
  2. Peripherals
  3. RGB LED
  4. Firmware control

LED functions

PreviousFirmware controlNextColor

Last updated 8 months ago

LED functions is the way you control your LEDs. There are two basic functions and some specific functions. The two basic ones are:

  • colorLED()

  • triggerLED()

These two alone will give you the freedom to do pretty much anything. The more tailored functions are a bit more limiting, but will do in one function what you'd need 20 triggerLED() functions to do.

There are specific functions that act on specific LED strips. colorLED() works on strip one. colorLED3() work on strip 3. triggerLED2() works on strip 2, etc.

Besides from the functions included in DDC, you can address the LED strips with commands from the Neopixel library as well. The LED strips are named LED1, LED2, LED3 and LED4. See list of commands

colorLED()

Allows you to set the color and brightness of one or more LEDs.

void colorLED(startLED, stopLED, color, brightness)

To make LED 5 to 9 plain blue with a brightnes of 50%:

colorLED(5,9,0x0000FF,50);

  • 1 or more LEDs

triggerLED()

Allows you to set the color and brightness of one or more LEDs under certain conditions. Also has the options of keeping all its LEDs cleared when not used, and to activate blinking.

To get access to things happening in the firmware and use this as a condition, there are you can use. These will return true under certain conditions.

void triggerLED(startLED, stopLED, condition, color, brightness, clearLEDs, blinkEnable, blinkOnTimer, blinkOffTimer)

Typed out and explained:

triggerLED(
0, //------------Starting on LED number 0
4, //------------Ending on LED 4, including LEDs 0-4
modButtonPressed(), //-------------Light the LED of this is true
0xFF0000, //-----Red color
80, //-----------Relative brightness 80%
false, //--------Will not clear LEDs when conditions are not met
true,  //--------Will blink
300,   //--------Will stay lit for 300 ms on blinking
2000); //--------Will turn off LED for 2000 ms on blinking
  • If you want the function to be always active, simply write true for the condition.

  • As default, clearLEDs and blinkEnable is set to true. blinkOnTime and blinkOffTimer is set to 500 ms. If you dont fill in anything for these values, defaults will be used:

triggerLED(7,10,true,0x803580, 85);

  • 1 or more LEDs

biteLED()

Premade solution for using LED indication on setting the bite point, typically the rev light streip. It requres at least 10 LEDs in a chain

  • You'll set a single or multiple LEDs to blink at a certain color when bite point setting is active.

  • A chain of 10 LEDs will represent numbers 0 to 10 (0 being none lit) that changes color as you move through the stages of setting the bite point.

void biteLED(biteEngageStartLED, biteEngageStopLED, engageBrightness, biteChainStartLED, biteBrightness, engageColor, step1Color , step2Color, step3Color, engageBlink)

Typed out and explained:

biteLED(
3, //------------Bite setting indicator starts on LED number 3
3, //------------Ending on LED number 3, i.e. including only LED number 3.
25, //-----------Relative brightness of indicator set to 25%
24, //-----------The 10-LED chain starts on LED nummber 24. Will include LEDs 24-33.
80, //-----------Relative brightness of bite value LEDs set to 80%
0xFF0000, //------Bite setting indicator is red.
0X00FF00, //------Bite value indicators are green on setting with increments of 10.
0X0000FF, //------Bite value indicators are blue on setting with increments of 1
0X802090, //------Bite value indicators are purple on setting with increments of 0.1
true);  //--------Engage indicator will blink
  • As a default, engageColor is set to orange, steps 1 -3 are teal - purple - orange and engageBlink is set to true. If you dont fill in anything for these values, defaults will be used:

biteLED(5,8,30,16,60);

  • 10 or more LEDs

rotaryLED()

void rotaryLED(switchNumber, startLED, positions, color, brightness, offset, reverse, backgroundColor, backgroundBrightness)

Typed out and explained:

rotaryLED(
2, //------------Tie to analog switch # 2
0, //------------Starting on LED number 0
12, //-----------This is a 12 position switch. LED numbers 0-11 will be used.
0x0000FF //------Blue color
80, //-----------Relative brightness 80%
0, //------------No offset
true, //---------Direction reversed
0xFF0000, //-----Background color red, optional
40);  //---------Relative background brightness 40%, optional

  • The offset allows you to match the LED and the switch position. If your first LED surrounding the rotary switch is at the bottom, looping around the top - and the first switch position is at the top, you'll need some offset. Ranges from 0 to <position -1>. So in the case above, from 0 to 11. A value of 1 will more it 1 position clockwise, a position of 11 will more it 11 positions clockwise (or 1 positions counter-clockwise).

  • The reverse setting will allow you to change the direction of the LED loop around the rotary switch, in case you circled it the wrong way.

  • The background color and brightness is optional to fil in, by default black and 25%.

  • As many LEDs as positions on your switch.

Ties x amount of LEDs to a x-position . The idea being that the LED will indicate the position of the switch. As the option to offset and reverse the LED direction, so it should always be able to match the switch position.

here.
triggers
rotary switch