Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
FerralCoder committed Feb 16, 2024
1 parent 8009a34 commit 88e957b
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
Empty file added .gitignore
Empty file.
7 changes: 7 additions & 0 deletions .theia/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.tabSize": 4,
"editor.renderWhitespace": "trailing",
"editor.insertSpaces": true,
"files.trimTrailingWhitespace": true,
"arduino.compile.warnings": "All"
}
19 changes: 19 additions & 0 deletions PinAssignments.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef PIN_ASSIGNMENTS_H
#define PIN_ASSIGNMENTS_H

// Each of these values corresponds to a pin on the Arduino Nano Every
enum PinAssignments : uint8_t {
// Ignition (digital input)
IgnitionPin = 8,

// LED indicating ready to sense ignition (digital out)
ReadyLedPin = 4,

// LED indicating ignition delay has completed. GO!! (digital out)
GoLedPin = 6,

// Delay control (analog in)
DelayControlPin = A1
};

#endif // PIN_ASSIGNMENTS_H
46 changes: 46 additions & 0 deletions RZR_Ignition_Delay_Indicator.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "PinAssignments.h"

#define DELAY_CONTROL_MULTIPLIER 4
#define MIN_IGNITION_DELAY_MS 1000
#define STABILIZATOIN_DELAY_MS 500

void setup()
{
// IN: Ignition wire
pinMode(IgnitionPin, INPUT);
// OUT: Ready LED
pinMode(ReadyLedPin, OUTPUT);
// OUT: Go LED
pinMode(GoLedPin, OUTPUT);
// IN: ADC from potentiometer to adjust delay (A0)
pinMode(DelayControlPin, INPUT);
analogReference(VDD);

// Insert artificial delay to make sure all signals from the car are stable
delay(STABILIZATOIN_DELAY_MS);

// Ready to sense ignition
digitalWrite(ReadyLedPin, HIGH);
}

void loop()
{
int DelayControlVal = 0;
long IgnitionDelay_ms = 0;

// Read delay control value from potentiometer (range 0 to 1023)
DelayControlVal = analogRead(DelayControlPin);

// Calculate delay
IgnitionDelay_ms = MIN_IGNITION_DELAY_MS + (DelayControlVal * DELAY_CONTROL_MULTIPLIER);

if (digitalRead(IgnitionPin) == HIGH)
{
// Start delay
delay(IgnitionDelay_ms);

// Light it up!!
digitalWrite(GoLedPin, HIGH);
digitalWrite(ReadyLedPin, LOW);
}
}

0 comments on commit 88e957b

Please sign in to comment.