Skip to content

Instantly share code, notes, and snippets.

@ednisley
Created August 12, 2023 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ednisley/b8080c78a1f39b35f07becb9faa71139 to your computer and use it in GitHub Desktop.
Save ednisley/b8080c78a1f39b35f07becb9faa71139 to your computer and use it in GitHub Desktop.
Arduino source code: Tour Easy front & rear running light
// Tour Easy Running Light
// Ed Nisley - KE4ZNU
// September 2021
// 2023-03 preprocessorize for front/rear lights
// https://github.com/markfickett/arduinomorse
#include <morse.h>
// Bafang headlight output pulls pin low
#define PIN_LIGHTMODE 2
#define PIN_OUTPUT 13
#define FRONT
#if defined(FRONT)
#define BLINKS "b e "
#define POLARITY false
#elif defined(REAR)
#define BLINKS "s "
#define POLARITY true
#else
#error "Needs FRONT or REAR"
#endif
// second param: true = active low output
LEDMorseSender Morser(PIN_OUTPUT,POLARITY,(float)10.0);
void setup()
{
pinMode(PIN_LIGHTMODE,INPUT_PULLUP);
Morser.setup();
Morser.setMessage(String("qst de ke4znu "));
Morser.sendBlocking();
Morser.setSpeed(75);
Morser.setMessage(String(BLINKS));
}
void loop()
{
if (!Morser.continueSending())
if (digitalRead(PIN_LIGHTMODE) == HIGH)
Morser.startSending();
else
digitalWrite(PIN_OUTPUT,HIGH); // constantly turn on in headlight mode
}
@ednisley
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment