Created
August 12, 2023 18:03
-
-
Save ednisley/b8080c78a1f39b35f07becb9faa71139 to your computer and use it in GitHub Desktop.
Arduino source code: Tour Easy front & rear running light
This file contains 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 | |
// 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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More details on my blog at https://softsolder.com/2023/08/22/tour-easy-running-lights-firmware/