Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 55
  • *Total: 56

Our Discord

Author Topic: Teensy as Joystick  (Read 62 times)

Offline kurt-olsson

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

747-400 Yoke Color
by rafalbb
[Today at 02:03:18 PM]
Overhead: Where to mount interface cards?
by helloo
[Today at 12:30:21 PM]
737 MAX Sismo soluciones (SPAIN)
by tennyson
[Today at 04:28:23 AM]
TV Screen Position
by iwik
[April 22, 2019, 07:53:38 PM]
Question on B737NG center pedestal instrument availability
by navymustang
[April 22, 2019, 05:05:09 PM]
Wanted - Jetmax B737 TQ
by kattz
[April 22, 2019, 12:57:09 AM]
Multi-Projector color calibration
by jmlohrenz
[April 21, 2019, 05:33:40 PM]
Bernard...info
by FredK
[April 20, 2019, 06:29:17 PM]
Complete 200 degree curved visual system with projectors
by fsaviator
[April 20, 2019, 04:25:12 PM]
For Sale GoFlight Jet Console, 2 Private Pilot Racks all with GoFlight Modules.
by blueskydriver
[April 20, 2019, 11:26:43 AM]
Old Projector(s)
by fsaviator
[April 20, 2019, 10:53:59 AM]
OEM 737NG project - Long overdue update
by Karl737
[April 19, 2019, 09:56:23 PM]
CPFlight 737 NG MCP Pro and Efis Pro
by patiju
[April 19, 2019, 06:14:33 PM]
Goflight Airliners collection stuff for sale
by Steenos
[April 19, 2019, 03:22:12 PM]
German B738NG Homecockpit-Projekt
by Joe Lavery
[April 19, 2019, 04:59:21 AM]
Teensy LC Throttle Quadrant
by RayS
[April 18, 2019, 03:38:14 PM]
FSDream Team Couatl crashes when shutting down computers - any ideas
by navymustang
[April 18, 2019, 08:25:11 AM]
FLIGHTSIMEXPO RELEASES 2019 SPEAKER SCHEDULE, ANNOUNCES NEW PARTNERSHIP WITH EAA
by 757Simulator
[April 18, 2019, 04:20:53 AM]
737-800 Arduino X-Plane Build
by kurt-olsson
[April 17, 2019, 05:10:03 AM]
Teensy as Joystick
by kurt-olsson
[April 16, 2019, 01:54:29 PM]
Which Processor i7 - 8700K or i7 - 9700K
by Joe Lavery
[April 15, 2019, 04:00:33 PM]
Computer / Projector Combo
by blueskydriver
[April 15, 2019, 02:50:24 PM]
Flyengravity desktop MIP
by Steenos
[April 15, 2019, 02:22:39 PM]
Join me on Vatsim Tonight
by Trevor Hale
[April 14, 2019, 05:07:50 PM]
Interfacing real instruments in p3d
by Steve Mount
[April 14, 2019, 04:56:08 PM]
Flight Sim Visual System on Public Surplus...
by bernard S
[April 14, 2019, 12:53:56 PM]
Aerosoft Australia 747 MCP
by 737simAdelaide
[April 14, 2019, 05:16:58 AM]
CPFlight 737 EL MCP For Sale
by 737simAdelaide
[April 14, 2019, 05:12:54 AM]
CPflight radios B737.
by avan1001
[April 14, 2019, 04:12:07 AM]
Anyone can recognize this material?
by 757Simulator
[April 14, 2019, 03:21:26 AM]