U.S. Air Force Senior Master Sgt. Mike Chandler, 142nd Maintenance
Squadron out of the Portland Air National Guard, displays his avionics
Electronics Systems Test Station (ESTS) cable tester that he designed

Photo by: Airman First Class Andrew Kobialka

As my I2C parts count is growing out of control, I have decided to split my work between two Arduinos, one will control the six (6) note 1 MCP23017 while the other will control my dual 2X 0.96" I2C Serial 128X64 LED OLED  displays, as they are mounted in a nice stand. This Arduino will also have a rotary encoder to select from the menu and this will be under interrupt control. I will most likely use the SPI bus converted to RS-485 for intercommunications. I found the following code for rotary encoder interrupts from the web.  I will use this as a starting point only. The Arduino should be mounted in a plastic box on the rear or bottom of the unit.  Each of the 2 parts of the system will have 2 RS-285 modules shown below. One of the monitors will show the list of cables to select for the test.

The second monitor will show the status of the tests. The test consists of several phases.

* Bas on Tech - Rotary Encoder and Interrupts
* This course is part of the courses on https://arduino-tutorials.net
* (c) Copyright 2018-2019 - Bas van Dijk / Bas on Tech
* This code and course is copyrighted. It is not allowed to use these courses commercially
* without explicit written approval
* YouTube: https://www.youtube.com/c/BasOnTech
* Facebook: https://www.facebook.com/BasOnTechChannel
* Instagram: https://www.instagram.com/BasOnTech
* Twitter: https://twitter.com/BasOnTech
* ---------------------------------------------------------------------------
* More info about the Rotary Encoder:
* https://en.wikipedia.org/wiki/Rotary_encoder
* GND --> GND black
* + --> 5V red
* SW --> 12 yellow
* DT --> 3 green (data)
* CLK --> 4 blue (clock)
int switchPin = 12// button pin
int switchState = HIGH;  // button value
int pinA = 4// Rotary encoder Pin A
int pinB = 3// Rotary encoder Pin B
int pinAstateCurrent = LOW;  // Current state of Pin A
int pinAStateLast = pinAstateCurrent;  // Last read value of Pin A
void setup() {
  Serial.begin (9600);  // Initialise the serial monitor
  pinMode (switchPin, INPUT_PULLUP);  // Enable the switchPin as input with a PULLUP resistor
  pinMode (pinA, INPUT);  // Set PinA as input
  pinMode (pinB, INPUT);  // Set PinB as input
  // Attach a CHANGE interrupt to PinB and execute the update function when this change occurs.
  attachInterrupt(digitalPinToInterrupt(pinB), update, CHANGE);
void loop() {
  switchState = digitalRead(switchPin);  // Read the digital value of the switch (LOW/HIGH)
  // If the switch is pressed (LOW), print message
  if (switchState == LOW) {
  Serial.println("Switch pressed");
void update() {
  /* WARNING: For this example I've used Serial.println within the interrupt callback. The Serial
  * library already uses interrupts which could cause errors. Therefore do not use functions
  * of the Serial libray in your interrupt callback.
  pinAstateCurrent = digitalRead(pinA);  // Read the current state of Pin A
  // If there is a minimal movement of 1 step
  if ((pinAStateLast == LOW) && (pinAstateCurrent == HIGH)) {
  if (digitalRead(pinB) == HIGH) {  // If Pin B is HIGH
  Serial.println("Right");  // Print on screen
  } else {
  Serial.println("Left");  // Print on screen
  pinAStateLast = pinAstateCurrent;  // Store the latest read value in the currect state variable
  1. All pins test that is to say end to end.
  2. pins are tested for shorts drive one
    pin at a time and read all pins
  3. At this time the only way to test for
    opens is test 1.

notes and updates*

  1. six (6) was added  July 1, 2021