Created
June 30, 2024 22:19
-
-
Save ednisley/4f439a76eabb5667bab7e72523ee7ba5 to your computer and use it in GitHub Desktop.
Arduino source code: Tour Easy Running Light - selectable output
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 | |
// 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 | |
} |
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://wp.me/poZKh-d8H