Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: teensy

  1. #1
    Junior Member
    Join Date
    Jan 2020
    Posts
    1

    teensy

    hi ppl

    im trying to set up a game controller from my old logitech controller. I want to use the pedals as they are ok and transform the brake padel with a load cell.
    so i hooked everything up and copy and pasted some code from everywhere i could get it.

    so this is my code

    Code:
    ///////////////////////////////////////////////////////////////////////
    // SIMPLEST LOAD CELL BRAKE PEDAL FOR RACING SIMULATION
    // by JS Stoezel
    // js.stoezel@gmail.com
    ///////////////////////////////////////////////////////////////////////
    
    ///////////////////////////////////////////////////////////////////////
    // INCLUDES
    ///////////////////////////////////////////////////////////////////////
    
    ///////////////////////////////////////////////////////////////////////
    // Get this library from this Git repository
    // https://github.com/aguegu/ardulibs/tree/master/hx711
    #include "HX711.h"
    ///////////////////////////////////////////////////////////////////////
    
    ///////////////////////////////////////////////////////////////////////
    // MACROS
    ///////////////////////////////////////////////////////////////////////
    // How many samples to take at initialization of the library to zero
    // out the offset of the load cell.
    #define BRAKE_PEDAL_LOAD_BEAM_CELL_TARE_REPS  10
    
    // Sanity check for the load cell readings. This will typically be to
    // prevent from loading negative values if/when the load cell is pulled
    // in the wrong direction
    #define BRAKE_PEDAL_LOAD_BEAM_CELL_MAX_VAL  2000000
    
    // This setting links the maximum effort applied to the pedal to the
    // maximum value sent to the joystick interface.
    // The joystick interface expects a value ranging from 0 t0 1023. Adjust
    // this number to your liking, so the joystick will read 1023 at the maximum
    // force you feel comfortable applying to the brake pedal (without braking it).
    // The hardware I am using is 3D printed and I do not recommend this value
    // Be set any lower than 1100. Any lower value will require more force to
    // be applied to the pedal, and may damage the 3D printed parts.
    #define BRAKE_PEDAL_LOAD_BEAM_CELL_SCALING  1100
    
    
    ///////////////////////////////////////////////////////////////////////
    // LOCAL VARIABLES
    ///////////////////////////////////////////////////////////////////////
    HX711 brake_pedal;
    ///////////////////////////////////////////////////////////////////////
    
    ///////////////////////////////////////////////////////////////////////
    // FUNCTIONS
    ///////////////////////////////////////////////////////////////////////
    
    ///////////////////////////////////////////////////////////////////////
    void setup()
    ///////////////////////////////////////////////////////////////////////
    {
      // Zero the pedal offset. This is is to compensate for the own weight
      // of the pedal. It is important not to apply any force to the pedal
      // While this is happening
      brake_pedal.begin(1 /* DAT */, 0 /* CLK */, 128 /* GAIN */); 
      brake_pedal.tare(BRAKE_PEDAL_LOAD_BEAM_CELL_TARE_REPS);
      
     // Joystick.useManualSend(true);
    } // setup
    
    ///////////////////////////////////////////////////////////////////////
    void loop()
    ///////////////////////////////////////////////////////////////////////
    {
      int32_t brake_value ;
      
      brake_value = brake_pedal.get_value(1);
    
      if((brake_value > BRAKE_PEDAL_LOAD_BEAM_CELL_MAX_VAL) || 
         (brake_value < 0))
      {
        brake_value = 0;
      }
      
      brake_value /= BRAKE_PEDAL_LOAD_BEAM_CELL_SCALING;
      
      Joystick.X(brake_value);
      Joystick.Y(analogRead(2));
      Joystick.Z(analogRead(3));
      
      Joystick.send_now();
    } // loop
    so i got the loadcell to work and i thought adding the other 2 pedals shouldnt be that big a deal. but i was wrong, i cant get it to work after reading and wathcing lots of tutorials. what i see is the brakepedal moving but the z is doing some random thing and the y isnt doing anything

    i must have done something wrong here. could you guys help me in the right direction?

  2. #2
    Senior Member
    Join Date
    Feb 2016
    Location
    Australia
    Posts
    267
    How are pedal electronics wired to pins 2 and 3?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •