Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 52
  • *Total: 53

Our Discord

Author Topic: Teensy as Joystick  (Read 94 times)

Offline kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,183
  • 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;
}

Offline kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,183
  • 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

Wanted - COMPLETE set of Boeing 727 or 737 rudder pedals
by kattz
[Today at 03:18:30 PM]
FLIGHTSIMEXPO LAUNCHES DISCOUNTED ADVANCE REGISTRATION FOR ORLANDO 2019 EVENT
by fsaviator
[Today at 12:48:37 PM]
Amphenol female pin size?
by mickc
[May 24, 2019, 08:37:21 PM]
737-800 Arduino X-Plane Build
by kurt-olsson
[May 24, 2019, 04:23:43 PM]
GSX across networked client visual computers
by FredK
[May 24, 2019, 03:32:34 PM]
Complete 737-800 cockpit - moving sale
by navymustang
[May 24, 2019, 09:33:59 AM]
Piper Aztec PA23-250 (Help Needed)
by Joe Lavery
[May 23, 2019, 05:30:35 AM]
What have you done for your simulator today?
by MistyBlue
[May 22, 2019, 11:08:26 PM]
Flightdeck Solutions to X-Plane Conversion Complete
by Michael_B737_ATP
[May 22, 2019, 05:42:18 PM]
X-Plane 737-800 Build
by jskibo
[May 22, 2019, 09:54:50 AM]
Serial Key
by luisgordo
[May 21, 2019, 05:40:44 PM]
Jetmax TQ - motorized it?
by FredK
[May 20, 2019, 07:58:36 AM]
Mickey's Flightdeck - A Boeing 737-800 Cockpit on Youtube
by Extraterra
[May 20, 2019, 02:47:37 AM]
FDS CDU old
by kattz
[May 19, 2019, 01:13:46 PM]
Join me on Vatsim Tonight
by Trevor Hale
[May 15, 2019, 01:58:50 PM]
Gauge circuit
by jackpilot
[May 15, 2019, 01:56:51 PM]
Prosim and RSP TQ interfacing
by jfuenmayor
[May 15, 2019, 08:53:22 AM]
Arduino Mega question Newbie
by Yair1956
[May 15, 2019, 02:23:57 AM]
f18 mfd
by bernard S
[May 14, 2019, 11:15:44 PM]
Multi-Projector color calibration
by fsaviator
[May 13, 2019, 04:32:23 PM]
Immersive Calibration Pro help?
by jskibo
[May 13, 2019, 09:22:00 AM]
KBD03 Keyboard Emulator
by Yair1956
[May 12, 2019, 03:52:05 PM]
5 Position Rotary Spring return Switch
by Yair1956
[May 12, 2019, 03:09:25 PM]
Flyengravity desktop MIP
by patiju
[May 11, 2019, 05:11:05 PM]
Pfd display.
by Patt737
[May 08, 2019, 12:48:32 PM]
Mini Sim
by jskibo
[May 08, 2019, 08:36:28 AM]
F16 Simulator For Sale
by blueskydriver
[May 08, 2019, 12:14:40 AM]
Wanted: Collins Style radios
by jkbarr30
[May 07, 2019, 08:23:32 PM]
Crap! 26V on 5V backlight!
by Steenos
[May 07, 2019, 05:33:46 PM]
Prosim 737 iOS help
by Aztrucker
[May 06, 2019, 11:56:30 PM]