-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8009a34
commit 88e957b
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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
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" | ||
} |
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
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 |
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
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); | ||
} | ||
} |