I am trying to find help on the forum with a project without luck. I am hoping I can get this going and then worry about packaging later. the DIP switch is basically the range sensor on the gear shifter. I want the out put to turn on a relay (supporting hardware of course) but just the output to turn on a led would be a solid start!
here is the diagram of the logic
this is what I gathered and put together which did'nt work. I have no experience with coding which is why it doesn't comppile successfully.. lol, but is so fascinating.
while searching, also trying to figure out switch case.. probably a better for this project?
void setup() {
// constants (is this the right label to use) labeled according to schematic
const int L1 = 2; // the number of the L# pin
const int L2 = 3;
const int L3 = 4;
const int L4 = 5;
const int L5 = 6;
const int RevOutput = 13; // to identify when in reverse
const int StartOk = 12; // to identify when in park
// initialize the pins as an output:
pinMode(RevOutput, OUTPUT);
pinMode(StartOk, OUTPUT);
// initialize the pins as an input:
pinMode(L1, INPUT);
pinMode(L2, INPUT);
pinMode(L3, INPUT);
pinMode(L4, INPUT);
pinMode(L5, INPUT);
}
void loop() {
if ( ( L1 == LOW) && (L2 == LOW) && (L3 == HIGH) && (L4 == HIGH) && (L5 == LOW))
// turn RevOutput on:
digitalWrite(RevOutput, HIGH);
if ( ( L1 == HIGH) && (L2 == HIGH) && (L3 == HIGH) && (L4 == LOW) && (L5 == LOW))
// turn StartOk on:
digitalWrite(StartOk, HIGH);
if ( ( L1 == HIGH) && (L2 == HIGH) && (L3 == LOW) && (L4 == HIGH) && (L5 == LOW)) {
// turn StartOk on:
digitalWrite(StartOk, HIGH);
} else {
// turn all Outputs off:
digitalWrite(RevOutput, LOW);
digitalWrite(StartOk, LOW);
}
}
I am only interested in the three states, Park, Reverse and Neutral
Any links or guidance you are willing to share, I'd appreciate it!
Thank you,
Clint