Jump to content

Recommended Posts

Posted

I stumbled upon a code and modified it a bit to be super useful and determining the outputs/patterns of any kind of aircraft equipment that has a state of either high/low. It will also show binary/gray code. You can use this information to write new/different class states if you are using DCS-Bios. I have successfully used this code to test the outputs so far for my TACAN and ARC-164 which work in my A10C simpit. Hopefully you folks can use it too. It will not show information regarding servos or synchro's nor analog pots. But, that could be added. This code is just simply a diagnostic output reader. Connect the board to common ground, wire the pins to any random digital arduino I/O and annotate in the code. Watch the serial monitor as you flip switches to see the outputs. Now, this code only looks at 9 outputs, BUT you can add additional lines for how ever many inputs you have! Check it out:

 
// set pin numbers to the 'const int switchPinx':

const int switchPin1 = 2; // the number of the switch’s pin
const int switchPin2 = 3; // the number of the switch’s pin
const int switchPin3 = 4; // the number of the switch’s pin
const int switchPin4 = 5; // the number of the switch’s pin
const int switchPin5 = 6; // the number of the switch’s pin
const int switchPin6 = 7; // the number of the switch’s pin
const int switchPin7 = 8; // the number of the switch’s pin
const int switchPin8 = 9; // the number of the switch’s pin
const int switchPin9 = 10; // the number of the switch’s pin

// set variables:

int switchState1 = 0; // variable for reading the switch’s status
int switchState2 = 0; // variable for reading the switch’s status
int switchState3 = 0; // variable for reading the switch’s status
int switchState4 = 0; // variable for reading the switch’s status
int switchState5 = 0; // variable for reading the switch's status
int switchState6 = 0; // variable for reading the switch’s status
int switchState7 = 0; // variable for reading the switch’s status
int switchState8 = 0; // variable for reading the switch’s status
int switchState9 = 0; // variable for reading the switch’s status



byte test = B0000; // Variable for printing value over serial debug

void setup() {
// Start serial debugging…
Serial.begin(250000);
// initialize the switch pins as an input:
pinMode(switchPin1, INPUT);
pinMode(switchPin2, INPUT);
pinMode(switchPin3, INPUT);
pinMode(switchPin4, INPUT);
pinMode(switchPin5, INPUT);
pinMode(switchPin6, INPUT);
pinMode(switchPin7, INPUT);
pinMode(switchPin8, INPUT);
pinMode(switchPin9, INPUT);

}

void loop(){
// read the state of the switch’s individual pins:
switchState1 = digitalRead(switchPin1);
switchState2 = digitalRead(switchPin2);
switchState3 = digitalRead(switchPin3);
switchState4 = digitalRead(switchPin4);
switchState5 = digitalRead(switchPin5);
switchState6 = digitalRead(switchPin6);
switchState7 = digitalRead(switchPin7);
switchState8 = digitalRead(switchPin8);
switchState9 = digitalRead(switchPin9);


// If the output state is high, the serial monitor will show HIGH. If not, it will show ---
if (switchState1 == HIGH) {
Serial.println("switchState1   ON"); 
}
else {
Serial.println("switchState1   ---");
}
 if (switchState2 == HIGH) {
Serial.println("siwtchState2   ON"); 
}
else {
Serial.println("switchState2   ---");
}
if (switchState3 == HIGH) {
Serial.println("switchState3   ON"); 
}
else {
Serial.println("switchState3   ---");
}
 if (switchState4 == HIGH) {
Serial.println("switchState4   ON"); 
}
else {
Serial.println("switchState4   ---");
}
 if (switchState5 == HIGH) {
Serial.println("switchState5   ON"); 
}
else {
Serial.println("switchState5   ---");
}
if (switchState6 == HIGH) {
Serial.println("siwtchState6   ON"); 
}
else {
Serial.println("switchState6   ---");
}
if (switchState7 == HIGH) {
Serial.println("switchState7   ON"); 
}
else {
Serial.println("switchState7   ---");
}
 if (switchState8 == HIGH) {
Serial.println("switchState8   ON"); 
}
else {
Serial.println("switchState8   ---");
}
 if (switchState9 == HIGH) {
Serial.println("switchState9   ON"); 
}
else {
Serial.println("switchState9   ---");
}

Serial.println("\n");

delay(2000);
}

  • 3 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...