-
Tour Easy Running Lights: Updated Lights
With the new battery mount & buck converter box installed on Mary’s bike, I updated the running light circuitry to match the ones on my bike. The original wiring just supplied 6.3 V from the headlight circuit, but now the four wire ribbon cable from the electronics box carries 6.3 VDC from the buck converter and a 6 VDC signal going high when the DPC-18 display’s “headlight” output goes active. The latter goes into an optoisolator pulling down Pin 2, telling the running light to stay on continuously.
The optoisolator sits next to the Arduino Nano’s Reset button:

Tour Easy Running Light – unified light top The black wire barely visible below the optoisolator jumpers Pin 3 to ground, telling the firmware that this is the front running light.
The black & white wires from the top of the optoisolator connect directly to the ribbon cable entering on the other side:

Tour Easy Running Light – unified light bottom The gray wrap of clear silicone tape mummifies the wire-to-wire soldered connectors.
The firmware now pays attention to the jumper input, so I need only one source file for both front and rear lights:
if (digitalRead(PIN_POSITION) == HIGH) { Blinks = String("i e "); // rear = occulting Polarity = true; } else { Blinks = String("n e "); // front = blinking Polarity = false; }It just doesn’t get much easier than that!
The Arduino source code as a GitHub Gist:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters// Tour Easy Running Light // Ed Nisley – KE4ZNU // September 2021 // 2023-03 preprocessorize for front/rear lights // 2024-06 input bit for front/rear // https://github.com/markfickett/arduinomorse #include <morse.h> // Bafang headlight output pulls pin low #define PIN_LIGHTMODE 2 // Jumper pin low for front light #define PIN_POSITION 3 // Current regulator Enable: positive to turn on #define PIN_OUTPUT 13 String Blinks; boolean Polarity; // second param: true = active low output MorseSender *Morser; void setup() { pinMode(PIN_LIGHTMODE,INPUT_PULLUP); pinMode(PIN_POSITION,INPUT_PULLUP); if (digitalRead(PIN_POSITION) == HIGH) { Blinks = String("i e "); // rear = occulting Polarity = true; } else { Blinks = String("n e "); // front = blinking Polarity = false; } Morser = new LEDMorseSender(PIN_OUTPUT,Polarity,(float)10.0); Morser->setup(); Morser->setMessage(String("qst de ke4znu ")); Morser->sendBlocking(); Morser->setSpeed(75); Morser->setMessage(Blinks); } void loop() { if (!Morser->continueSending()) if (digitalRead(PIN_LIGHTMODE) == HIGH) Morser->startSending(); else digitalWrite(PIN_OUTPUT,HIGH); // constantly turn on in headlight mode }