Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 70
  • *Total: 71

Our Discord

Author Topic: Teensy as Joystick  (Read 123 times)

Online kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,198
  • 737 -mixed year OEM panel builder.
  • First Name: Peter
  • Home Location: Gothenburg
Teensy as Joystick
« on: April 16, 2019, 12:49:54 PM »
Simplest code ever.

I plug my Teensy in, it works, i calibrate my joystick in X-Plane 11. Once i click Done and return to flight, the joystick stops working after about 2 seconds.

I disconnect it, redo the calibration and it works for... 2 sec.

I am out of ideas, any help is really appreciated.

Teensy 3.2, USB Type: Flight Sim Controls + Joystick.

Code:


float roll = 0;
float pitch = 0;


void setup() {
  pinMode(23, INPUT_PULLUP);
  pinMode(22, INPUT_PULLUP);
   

  analogReadResolution(16);


   
}

void loop() {
   
  //FlightSim.update();

  int rollValue1Avg = 0;
  for(int i = 0; i < 20;i++) {
    rollValue1Avg += analogRead(23);
  }
  rollValue1Avg = rollValue1Avg / 20;

  int pitchValue1Avg = 0;
  for(int i = 0; i < 20;i++) {
    pitchValue1Avg += analogRead(22);
  }
  pitchValue1Avg = pitchValue1Avg / 20;
 
  roll = mapfloat(rollValue1Avg,12000,2000,0,1023);
  pitch = mapfloat(pitchValue1Avg,9200,15700,0,1023);


 
  Joystick.X(roll);
  Joystick.Y(pitch);
  delay(50);
}

float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
 return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

Online kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,198
  • 737 -mixed year OEM panel builder.
  • First Name: Peter
  • Home Location: Gothenburg
Re: Teensy as Joystick
« Reply #1 on: April 16, 2019, 01:54:29 PM »
Hm... think i solved it, use only keybourd / mouse / joystick in USB Type without Flight Sim Control and then it works.

 

FlightSimExpo 2019

FsExpo

COUNTDOWN TO WF2019


WORLDFLIGHT TEAM USA

Will Depart in...

Recent Posts

Flooring Installed!
by kurt-olsson
[Today at 11:27:45 AM]
737-800 Arduino X-Plane Build
by kurt-olsson
[Today at 11:26:12 AM]
737 Throttle Conversion OC + ProSim
by kattz
[June 16, 2019, 11:39:03 AM]
A friendly FYI on Boeing rudder pedals
by kattz
[June 15, 2019, 10:36:39 AM]
Wanted - 737 Audio Panels - OEM
by jackpilot
[June 14, 2019, 08:08:09 PM]
2020 Microsoft Flight Simulator - new at E3 2019
by 757Simulator
[June 14, 2019, 03:39:07 AM]
737 starter switch mechanism
by paulnd
[June 13, 2019, 02:58:39 PM]
Make up your mind, Microsoft!
by jmlohrenz
[June 12, 2019, 07:25:10 PM]
What have you done for your simulator today?
by C150DIY
[June 12, 2019, 12:53:27 PM]
Complete 737-800 cockpit - moving sale
by FaustoP
[June 12, 2019, 01:26:39 AM]
Flyengravity desktop MIP
by patiju
[June 10, 2019, 01:01:06 PM]
the perfect thing to complete your sim hanger
by fsaviator
[June 09, 2019, 03:12:50 PM]
Wanted - COMPLETE set of Boeing 727 or 737 rudder pedals
by kattz
[June 08, 2019, 01:26:09 PM]
For sale: 200° Curved screen with 3 projectors
by sim172
[June 08, 2019, 09:07:03 AM]
Visual system screen by Northern Flight Sim for sale $500
by peterkwu
[June 08, 2019, 06:07:39 AM]
Wanted: GoFlight T8
by C150DIY
[June 07, 2019, 02:32:29 PM]
For Sale - CPFlight MCP737 + EFIS
by ZillaUK
[June 07, 2019, 09:54:58 AM]
737 FWD Overhead Switch Diagram
by bernard S
[June 07, 2019, 08:21:46 AM]
Change the Forum Theme to suit your own Needs.
by AdamMilstead
[June 07, 2019, 06:20:41 AM]
Aileron & Elevator jump back to center
by iwik
[June 06, 2019, 08:01:24 PM]
Join me on Vatsim Tonight
by Trevor Hale
[June 05, 2019, 05:17:13 PM]
Machinery for home cockpit building
by giaviv
[June 04, 2019, 04:12:10 PM]
PROMOCION STEERING FREE
by alvaro castillo
[June 04, 2019, 11:42:43 AM]
FLIGHTSIMEXPO LAUNCHES DISCOUNTED ADVANCE REGISTRATION FOR ORLANDO 2019 EVENT
by fsaviator
[June 03, 2019, 06:52:44 PM]
Question about linking the yokes
by jackpilot
[June 01, 2019, 02:22:10 PM]
Wanted: Jetmax 737
by nisx
[May 30, 2019, 01:49:24 AM]
Cessna 150 Builder
by C150DIY
[May 27, 2019, 04:59:48 AM]
A trick to get SPST toggles interfaced to XPlane 11 Easily...
by C150DIY
[May 26, 2019, 02:13:42 PM]
Amphenol female pin size?
by mickc
[May 24, 2019, 08:37:21 PM]
GSX across networked client visual computers
by FredK
[May 24, 2019, 03:32:34 PM]