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. Digital outputs

Firmware control

PreviousSimHub controlNextPWM / Circuit control

Last updated 9 months ago

Output functions is the way you control your outputs through the firmware directly, not using simHub. There are three functions that should cover most of your needs:

  • setOutput()

  • triggerOutput()

  • rotaryOutput()

triggerOutput alone will give you the freedom to do pretty much anything.

setOutput()

Allows turn on/off a specific output on a specific hub.

void setOutput(hub, slot, value)

To turn on output slot 7 on hub 2:

setOutput(2,7, true);

  • Set up at least 1 output hub

triggerOutput()

Allows you to turn on/off a specific output on a specific hub under certain conditions. Also allows you to make the output "blink", turning it on/off at given time intervals.

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 triggerOutput(hub, slot, condition, blinkEnable, blinkOnTimer, blinkOffTimer)

Typed out and explained:

triggerOutput(
1, //------------Output hub 1
4, //------------Slot 4
modButtonPressed(), //-------------Turn on if this is true
true,      //-----Blinking enabled
300,       //--------Will stay lit for 300 ms on blinking
2000);     //--------Will turn off LED for 2000 ms on blinking

In another example, lets turn on output hub 2, slot 11 and 12 if my button on row4/column5 is pressed, no blinking:

triggerOutput(2,11,buttonPressed(4,5),false, 0, 0);
triggerOutput(2,11,buttonPressed(4,5),false, 0, 0);
  • Set up at least 1 output hub

rotaryOutput()

Pairs an output hub to a rotary switch to make a single output slot on the hub activate depending on the position of the rotary switch. Will work for any amount of positions (up to 16) and has an offset setting to accurately match the rotary switch.

void rotaryOutput(analogChannel, hub, startPin, offset, positions, reverse)

Typed out and explained:

rotaryOutput(
1, //------------Rotary switch is on analog channel 1
4, //------------Pair to output hub number 4
1, //------------Starting on output hubs first slot
0, //------------No offset. Can be both positive or negative
12, //-----------Rotary switch has 12 positions
false); //-------Switch rotation direction not reversed

All in all without the comments:

rotaryOutput(1,4,1,0,12,false);
  • Set up at least 1 output hub

  • Rotary switch

triggers