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

Shift register

Setting up the shift registers is pretty much straight forward, it is all done in 11_ShiftRegisters.ino

11_ShiftRegisters.ino

//----------------------------------------------------------------------------
// ------------------------- SHIFT REGISTER SETUP ----------------------------
//----------------------------------------------------------------------------

#define SRCOUNT 0

//----------------------------------------------------------------------------
// ---------------------------- CHAIN #1 SETUP -------------------------------
//----------------------------------------------------------------------------

#define SR1CHAIN 1
#define SR1DATA 2
#define SR1CLOCK 3
#define SR1LATCH 4

//----------------------------------------------------------------------------
// ---------------------------- CHAIN #2 SETUP -------------------------------
//----------------------------------------------------------------------------

#define SR2CHAIN 1
#define SR2DATA 2
#define SR2CLOCK 3
#define SR2LATCH 4

//----------------------------------------------------------------------------
// ---------------------------- CHAIN #3 SETUP -------------------------------
//----------------------------------------------------------------------------

#define SR3CHAIN 1
#define SR3DATA 2
#define SR3CLOCK 3
#define SR3LATCH 4

//----------------------------------------------------------------------------
// ---------------------------- CHAIN #4 SETUP -------------------------------
//----------------------------------------------------------------------------

#define SR4CHAIN 1
#define SR4DATA 2
#define SR4CLOCK 3
#define SR4LATCH 4
  • #define SRCOUNT 0 -> How many chains you'll be using. 0 to 4. 0 will inactivate SR reading.

  • Set up as many chaines as stated in SRCOUNT, starting with chain 1.

    • CHAIN is the amount of SR chips in this chain

    • DATA is the pin number used for DATA on this chain

    • CLOCK is the pin number used for CLOCK on this chain

    • LATCH is the pin number used for LATCH on this chain.

Example: 2 chains, 6 SR in the first, 1 in the second. Sharing CLOCK and LATCH, not sharing DATA pins (don't share DATA pins, it wont work).

//----------------------------------------------------------------------------
// ------------------------- SHIFT REGISTER SETUP ----------------------------
//----------------------------------------------------------------------------

#define SRCOUNT 2

//----------------------------------------------------------------------------
// ---------------------------- CHAIN #1 SETUP -------------------------------
//----------------------------------------------------------------------------

#define SR1CHAIN 6
#define SR1DATA 8
#define SR1CLOCK 10
#define SR1LATCH 15

//----------------------------------------------------------------------------
// ---------------------------- CHAIN #2 SETUP -------------------------------
//----------------------------------------------------------------------------

#define SR2CHAIN 1
#define SR2DATA 7
#define SR2CLOCK 10
#define SR2LATCH 15

//----------------------------------------------------------------------------
// ---------------------------- CHAIN #3 SETUP -------------------------------
//----------------------------------------------------------------------------

#define SR3CHAIN 1
#define SR3DATA 2
#define SR3CLOCK 3
#define SR3LATCH 4

//----------------------------------------------------------------------------
// ---------------------------- CHAIN #4 SETUP -------------------------------
//----------------------------------------------------------------------------

#define SR4CHAIN 1
#define SR4DATA 2
#define SR4CLOCK 3
#define SR4LATCH 4
PreviousTrigger controlNextI2C devices

Last updated 1 year ago