Hi again, I'm tinkering on tinkercad on a project. I amazed myself on how far I think i got, but cannot google my way out of this.
Hopefully the link to the tinker cad works?
the button and switch on the far left do the same thing, one is momentary, one is manual to test.
center board, left is LOW speed. other is HIGH Speed, potentiometer reads, doesnt do anything
here is a link to the tinkercad public version
[public]()
It sems to read read correctly, Low speed, high speed, and Park, all display correctly and circuit operates exactly as I think it would.
I cant google the answer, the question is how would I incorporate the delay string, or function.
The switch is a 2 wire, most likely a rheostat. Ohm range is not linear as to be expected, but range is about 0-4k ohms
In tinker cad the displayed value for:
100 ohm is a value of 2
4000 ohm is a value of 76
I don't know how to incorporate a command to make this operate as intended.
I don't know how to map it, I seen one thread that showed a setup for a potentiometer 1024 / # which would divide the value by # and have # of outputs from the potentiometer, but again, the thread didnt say how to apply it.
for range, in this case 2 - 76........ 76/2 (2 being the # of speeds within the potentiometer range) would be 38... from what i understood range 2-38 would be one state and range 39-76 would be other state? again, don't know how to apply the code
Also, will the arduinoUno be ok with multiple input_PULLUP pins?
trying to see if the code is displayed correctly below
const int ParkPin = 11; //park
const int HighPin = 2; //high
const int LowPin = 4; //low
const int DelayPin = A1; //delay
int analogINPUT(A1);
bool ParkState = 0;
bool HighState = 0;
bool LowState = 0;
int DelayState = 0;
int PosVal = 0;
int OldPosVal = 0;
const int LowOutputPin = 13; // Low out
const int HighOutputPin = 12; // High out
void setup()
{
Serial.begin(115200);
Serial.println("+++++WiperSelectionExample+++++");
// initialize the pins as an output:
pinMode(LowOutputPin, OUTPUT);
pinMode(HighOutputPin, OUTPUT);
// initialize the pins as an input:
pinMode(ParkPin, INPUT_PULLUP); // value 1
pinMode(HighPin, INPUT_PULLUP); // value 2
pinMode(LowPin, INPUT_PULLUP); // value 4
pinMode(DelayPin, INPUT_PULLUP); // value 8
}
void loop()
{
ParkState = digitalRead(ParkPin);
HighState = digitalRead(HighPin);
LowState = digitalRead(LowPin);
DelayState = analogRead(DelayPin);
PosVal = (ParkState * 1) + (HighState * 2) + (LowState * 4);// + (DelayState); // calculate Position selected
if (PosVal != OldPosVal) // Check to see if new Position selected.
{
Serial.print("Park Signal = ");
Serial.print(ParkState);
Serial.print(" High Signal = ");
Serial.print(HighState);
Serial.print(" Low Signal = ");
Serial.print(LowState);
Serial.print(" Delay = ");
Serial.print(DelayState);
Serial.print(" PosVal = ");
Serial.println(PosVal);
switch (PosVal)
{ digitalWrite(LowOutputPin, HIGH);
case 0:
Serial.println("HIGH + Park Selected");
digitalWrite(HighOutputPin, LOW);
digitalWrite(LowOutputPin, HIGH);
break;
case 1:
Serial.println("HIGH Selected");
digitalWrite(HighOutputPin, HIGH);
digitalWrite(LowOutputPin, HIGH);
break;
case 2:
Serial.println("LOW + Park Selected");
digitalWrite(HighOutputPin, LOW);
digitalWrite(LowOutputPin, HIGH);
break;
case 3:
Serial.println("LOW Selected");
digitalWrite(HighOutputPin, LOW);
digitalWrite(LowOutputPin, HIGH);
break;
case 6:
Serial.println("PARK Selected");
digitalWrite(HighOutputPin, LOW);
digitalWrite(LowOutputPin, LOW);
break;
case 7:
Serial.println("OFF Selected");
digitalWrite(HighOutputPin, LOW);
digitalWrite(LowOutputPin, HIGH);
break;
default:
Serial.println("Invalid Selection");
//digitalWrite(HighOutputPin, LOW);
//digitalWrite(LowOutputPin, LOW);
break;
}
OldPosVal = PosVal;
}
}
thanks for links or input,
Clint