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
  • Planning with direct wiring
  • Coding with direct wired switches
  1. 1: Project planning
  2. Switch inputs

Direct

PreviousSwitch tableNextShift register

Last updated 1 year ago

You can also include switches that are to the microcontroller. The requirement here is that each switch has its own pin on the microcontroller. Or in the case of a 2-bit encoder -> two pins. For a funky switch -> 7 pins, you get the idea.

Planning with direct wiring

These swiches will need switch table adress in order to work. This means you plan these switches as if they are part of the table. Follow the guide and rules for

There are also some extra rules to follow:

  • In case of a hybrid project, where some switches are wired in a matrix, and some switches wired directly (typically pushbuttons in matrix and encoders directly to the microcontroller), the direct wired switches should be either on an isolated row or an isolated column (or on a row/column together with shift registers). An isolated row is the most processor friendly solution.

The example below has three non-matrix 2-bit encoders (red) and a button matrix.

INCORRECT

The rows or columns with direct wired switches aren't real matrix wired rows, and there is no microcontroller input pin associated with them. Putting matrix wired switches on these rows won't work, as they won't be registered.

  • In the case of a project with only direct wiring, you might as well just make a single row with loads of columns, as that will give you the best fit without any open slots. However, that might not give you a very good overview.

The example above has three 2-bit encoders and 10 pushbuttons, none of them are wired in a matrix. It can be organized in a 1 x 16 or a 4 x 4 table, or anything in between. It doesn't matter much, as no actual pins are associated with the rows and columns.

Pins

Direct wired switches require as many pins as blocks it uses in the switch table. In the example just above, 16 pins are needed. In a hybrid solution, you need the pins required for the matrix wired switches + a pin for each block of direct wired switches.

In this example, you need 2 + 2 + 2 pins for direct wired switches, and since row 1 and row 2 are "fake" rows, you only need pins for row 3-5 and columns 1 - 4. A total of 13 pins.

Coding with direct wired switches

CORRECT
image

A little bit of extra attention to the code is required, more on that.

wired directly
building a switch table.
here
CORRECT