Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 0
  • *Guests: 66
  • *Total: 66

Our Discord

Author Topic: Flight Control Panel A Side  (Read 177 times)

Offline kurt-olsson

  • I am chained to this website!
  • *
  • Posts: 1,200
  • 737 -mixed year OEM panel builder.
  • First Name: Peter
  • Home Location: Gothenburg
Flight Control Panel A Side
« on: February 04, 2019, 04:34:38 PM »
This is one side of my Flight Control Panel. I Hate this code, i hate the Commands.
If anyone has a better way of doing this let me know!

const int PIN_KORRY_PUSH_TO_TEST = 16;
const int PIN_KORRY_YAW_DAMPER = 17;
const int PIN_KORRY_AUTO_SLAT_FAIL = 20;
const int PIN_KORRY_FEEL_DIFF_PRESS = 10;
const int PIN_KORRY_MACH_TRIM_FAIL = 9;
const int PIN_KORRY_SPEED_TRIM_FAIL = 6;

const int PIN_SWITCH_YAW_DAMPER = 13;
const int PIN_SWITCH_FLIGHT_CONTROL_A_STBY_RUD = 18;
const int PIN_SWITCH_FLIGHT_CONTROL_A_ON = 19;
const int PIN_SWITCH_FLIGHT_CONTROL_B_STBY_RUD = 14;
const int PIN_SWITCH_FLIGHT_CONTROL_B_ON = 15;

const int PIN_RELAY_YAW_DAMPER = 21;

FlightSimFloat xPlane_readonly_flt_ctr_A_cover_pos;
FlightSimFloat xPlane_readonly_flt_ctr_B_cover_pos;

FlightSimCommand Command_flt_ctr_A_cover;
FlightSimCommand Command_flt_ctr_B_cover;

FlightSimCommand Command_flt_ctr_A_up;
FlightSimCommand Command_flt_ctr_A_dn;

FlightSimFloat xPlane_flt_ctr_A_pos;

FlightSimCommand Command_flt_ctr_B_up;
FlightSimCommand Command_flt_ctr_B_dn;

FlightSimFloat xPlane_flt_ctr_B_pos;


void setup() {
  FlightSim.update();
   
  //Serial.begin(9600);
  pinMode(PIN_KORRY_PUSH_TO_TEST, OUTPUT);
  pinMode(PIN_KORRY_YAW_DAMPER, OUTPUT);
  pinMode(PIN_KORRY_AUTO_SLAT_FAIL, OUTPUT);
  pinMode(PIN_KORRY_FEEL_DIFF_PRESS, OUTPUT);
  pinMode(PIN_KORRY_MACH_TRIM_FAIL, OUTPUT);
  pinMode(PIN_KORRY_SPEED_TRIM_FAIL, OUTPUT);

  pinMode(PIN_SWITCH_YAW_DAMPER,INPUT_PULLUP);
  pinMode(PIN_SWITCH_FLIGHT_CONTROL_A_STBY_RUD,INPUT_PULLUP);
  pinMode(PIN_SWITCH_FLIGHT_CONTROL_A_ON,INPUT_PULLUP);
  pinMode(PIN_SWITCH_FLIGHT_CONTROL_B_ON,INPUT_PULLUP);
  pinMode(PIN_SWITCH_FLIGHT_CONTROL_B_STBY_RUD,INPUT_PULLUP);

  pinMode(PIN_RELAY_YAW_DAMPER,OUTPUT);

  xPlane_readonly_flt_ctr_A_cover_pos = XPlaneRef("laminar/B738/switches/flt_ctr_A_cover_pos");
  xPlane_readonly_flt_ctr_B_cover_pos = XPlaneRef("laminar/B738/switches/flt_ctr_B_cover_pos");

  Command_flt_ctr_A_cover = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_A_cover");
  Command_flt_ctr_B_cover = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_B_cover");

  Command_flt_ctr_A_up = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_A_up");
  Command_flt_ctr_A_dn = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_A_dn");

  xPlane_flt_ctr_A_pos = XPlaneRef("laminar/B738/switches/flt_ctr_A_pos");

  Command_flt_ctr_B_up = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_B_up");
  Command_flt_ctr_B_dn = XPlaneRef("laminar/B738/toggle_switch/flt_ctr_B_dn");

  xPlane_flt_ctr_B_pos = XPlaneRef("laminar/B738/switches/flt_ctr_B_pos");
}

void loop() {
 FlightSim.update(); 
  // put your main code here, to run repeatedly:
 analogWrite(PIN_KORRY_PUSH_TO_TEST,255);
 analogWrite(PIN_KORRY_YAW_DAMPER,255);
 analogWrite(PIN_KORRY_AUTO_SLAT_FAIL,255);
 analogWrite(PIN_KORRY_FEEL_DIFF_PRESS,255);
 analogWrite(PIN_KORRY_MACH_TRIM_FAIL,255);
 analogWrite(PIN_KORRY_SPEED_TRIM_FAIL,255);

 digitalWrite(PIN_RELAY_YAW_DAMPER,HIGH);

 //THIS CODE IS JUST BS, MUST BE A BETTER WAY OF DOING THIS!
 
  if (xPlane_readonly_flt_ctr_A_cover_pos == 0.0f) {
    Command_flt_ctr_A_cover.once();   
  }
  if (xPlane_readonly_flt_ctr_B_cover_pos == 0.0f) {
    Command_flt_ctr_B_cover.once();   
  }

 
  if (xPlane_readonly_flt_ctr_A_cover_pos == 1 && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_STBY_RUD) == LOW && xPlane_flt_ctr_A_pos != -1) {
    Command_flt_ctr_A_up.once();
    delay(200);
  }
  if (xPlane_readonly_flt_ctr_A_cover_pos == 1 && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_ON) == LOW && xPlane_flt_ctr_A_pos != 1) {
    Command_flt_ctr_A_dn.once();
    delay(200);
  }
  if (digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_STBY_RUD) == HIGH && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_ON) == HIGH) {
    if (xPlane_flt_ctr_A_pos == -1)
      Command_flt_ctr_A_dn.once();
    if (xPlane_flt_ctr_A_pos == 1)
      Command_flt_ctr_A_up.once();
      delay(200);
  }



  if (xPlane_readonly_flt_ctr_B_cover_pos == 1 && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_STBY_RUD) == LOW && xPlane_flt_ctr_B_pos != -1) {
    Command_flt_ctr_B_up.once();
    delay(200);
  }
  if (xPlane_readonly_flt_ctr_B_cover_pos == 1 && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_ON) == LOW && xPlane_flt_ctr_B_pos != 1) {
    Command_flt_ctr_B_dn.once();
    delay(200);
  }
  if (digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_STBY_RUD) == HIGH && digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_ON) == HIGH) {
    if (xPlane_flt_ctr_B_pos == -1)
      Command_flt_ctr_B_dn.once();
    if (xPlane_flt_ctr_B_pos == 1)
      Command_flt_ctr_B_up.once();
      delay(200);
  }

 
 
 //Serial.println(digitalRead(PIN_SWITCH_YAW_DAMPER));
 //Serial.print(digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_STBY_RUD));
 //Serial.print(digitalRead(PIN_SWITCH_FLIGHT_CONTROL_A_ON));
 //Serial.print(digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_STBY_RUD));
 //Serial.print(digitalRead(PIN_SWITCH_FLIGHT_CONTROL_B_ON));

 

  delay(20);
 
 
 
}

 

FlightSimExpo 2019

FsExpo

Recent Posts

How much room between center pedestal and seat?
by kurt-olsson
[Today at 01:04:09 AM]
Flooring Installed!
by jackpilot
[June 24, 2019, 08:17:12 PM]
2020 Microsoft Flight Simulator - new at E3 2019
by blueskydriver
[June 24, 2019, 02:29:16 PM]
How to install DZUS fasteners?
by Buster99
[June 22, 2019, 04:12:34 PM]
Desert Air Spares - Trustworthy?
by kattz
[June 22, 2019, 12:40:51 PM]
Wanted - 737 Audio Panels - OEM
by jackpilot
[June 20, 2019, 12:26:51 PM]
Throttletek 737 Throttle For Sale
by kevinsayre
[June 19, 2019, 03:57:33 PM]
For sale - rudder pedals and linkages - pending to Craig
by Caflyt
[June 19, 2019, 07:49:14 AM]
737-800 Arduino X-Plane Build
by kurt-olsson
[June 18, 2019, 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]
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]
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]