Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

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

Our Discord

Author Topic: Teensy as Joystick  (Read 191 times)

Offline kurt-olsson

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

 

COUNTDOWN TO WF2019


WORLDFLIGHT TEAM USA

Will Depart in...

Recent Posts

Hi everyone!
by fsaviator
[Today at 04:07:47 PM]
737-800 Front window post size
by fordgt40
[Today at 03:14:49 PM]
Shipping Woes
by Caflyt
[Today at 10:47:49 AM]
Official WF 2019 Route
by dougsnow
[August 21, 2019, 07:49:35 PM]
Worldflight 2019 Open for Business
by Trevor Hale
[August 21, 2019, 08:28:13 AM]
More ?'s - annunciators?
by kattz
[August 21, 2019, 05:44:21 AM]
Looking for annunciators
by kattz
[August 19, 2019, 10:36:39 PM]
OK, So here we go!
by Caflyt
[August 19, 2019, 02:32:28 PM]
Flight Illusion Boeing Press Gauge for sale
by XOrionFE
[August 19, 2019, 08:40:35 AM]
Shell placement and yoke placement questions
by helloo
[August 18, 2019, 02:37:26 PM]
panel sismo oh
by gufau
[August 17, 2019, 04:17:00 AM]
My next sim?
by fsaviator
[August 16, 2019, 06:54:51 PM]
What have you done for your simulator today?
by blueskydriver
[August 14, 2019, 10:35:26 AM]
Looking for gear lever from 747-400, 757
by navymustang
[August 13, 2019, 10:05:44 AM]
Quick way to attach low res/smaller file size pics in your posts...
by Vincent T.
[August 12, 2019, 09:58:46 PM]
Cant post attachments from my iphone
by Trevor Hale
[August 12, 2019, 09:26:08 AM]
For Sale: Engravity 737 Window Frames
by Caflyt
[August 11, 2019, 05:02:28 PM]
737-800 Arduino X-Plane Build
by kurt-olsson
[August 10, 2019, 01:43:57 PM]
Help identifying a connector
by kurt-olsson
[August 10, 2019, 10:59:31 AM]
items/oem from overhead
by gufau
[August 09, 2019, 12:06:59 PM]
For Sale GoFlight Jet Console, 2 Private Pilot Racks all with GoFlight Modules.
by blueskydriver
[August 08, 2019, 09:40:02 PM]
Flightdeck Solutions Works with X-Plane11
by Michael_B737_ATP
[August 07, 2019, 02:59:21 PM]
Boeing Dual Linked Yokes for sale
by tennyson
[August 07, 2019, 07:34:58 AM]
CPFLight Backlighting
by mickc
[August 05, 2019, 10:09:53 PM]
Three Projector 210 degree with P3D4
by Nat Crea
[August 03, 2019, 08:36:50 PM]
Looking for part numbers from the 737 NG IPC
by mickc
[August 02, 2019, 11:20:49 PM]
WF2019
by Sam Llorca
[August 02, 2019, 09:22:56 PM]
Teensy LC Fuel Panel A (top)
by bernard S
[August 02, 2019, 06:09:00 PM]
737 overhead
by nigel27
[July 28, 2019, 11:50:47 PM]