Rav3nX Posted October 18, 2020 Posted October 18, 2020 (edited) Thought I would share this; its a script to identify input pin numbers for helping setup DCS BIOS etc; Lots of times I have pined through a giant connector; and rather than heaps of work keeping track of it all, its easier to work it out at the end. So here you go; just upload this to the board then open the serial monitor in arduino IDE. Press your buttons and you will get the pin number. EDIT: Obviously this is built for the MEGA, change loop numbers to suit your pin count. //Pin state change serial printer int PinStates[54]; int A_PinStates[16]; int APinVals[16]; //char aPins[16] = {'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10', 'A11','A12', 'A13', 'A14', 'A15',}; static const uint8_t analog_pins[] = {A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15}; void setup() { Serial.begin(9600); for(int i = 3; i <= 53; i++) { pinMode(i, INPUT_PULLUP); } for (int i = 0; i < 16; i++) { pinMode(analog_pins[i], INPUT_PULLUP); } } void loop() { for (int i = 3; i <= 53; i++) { int PinNumber = i; //i + 4; int CurrentState = digitalRead(PinNumber); if(CurrentState != PinStates[i]) { Serial.print(PinNumber); Serial.print(" D"); Serial.print(i); Serial.print(" [ ");Serial.print(CurrentState); Serial.println(" ]"); } PinStates[i] = CurrentState; } for (int y = 0; y <= 16; y++) { int PinNumber = y; //i + 4; int CurrentState = digitalRead(analog_pins[y]); if(CurrentState != A_PinStates[y]) { Serial.print(analog_pins[y]); Serial.print(" A"); Serial.print(y); Serial.print(" [ "); Serial.print(CurrentState); Serial.println(" ]"); } A_PinStates[y] = CurrentState; } delay(10); } } Edited October 18, 2020 by Rav3nX
Recommended Posts