Open mursa1en opened 4 months ago
int switch = 0;
int switchValue = analogRead(A0); //Read analog value from A0 pin example
//For 1 position switch:
if (switchValue >= 995 && switchValue <= 1005) {
switch = 0;
}
//For 3 position switch:
else if (switchValue >= 1990 && switchValue <= 2008) {
switch = 2;
}
//For midle position switch:
else if (switchValue == 0) {
switch = 1;
}
Meaning switch position
switch = 0; => 1000 switch = 1; => 1500 switch = 2; => 2000
int switch1 = 0;
int switch2 = 0;
int switch3 = 0;
int switchValue = analogRead(A0); //Read analog value from A0 pin example
//For 1st switch:
if (switchValue >= 995 && switchValue <= 1005) {
switch1 = 1;
}
//For 2nd switch:
else if (switchValue >= 1990 && switchValue <= 2008) {
switch2 = 1;
}
//For 3rd switch:
else if (switchValue >= 2990 && switchValue <= 3008) {
switch3 = 1;
}
//For 1th and 2th switch:
else if (switchValue >= 660 && switchValue <= 670) {
switch1 = 1;
switch2 = 1;
}
//For 1th 2th 3th switch:
else if (switchValue >= 540 && switchValue <= 550) {
switch1 = 1;
switch2 = 1;
switch3 = 1;
}
//For 2th 3th switch:
else if (switchValue >= 1998 && switchValue <= 2004) {
switch2 = 1;
switch3 = 1;
}
//For 1th 3th switch:
else if (switchValue >= 745 && switchValue <= 755) {
switch1 = 1;
switch3 = 1;
}
I have been using it for a while and have noticed the absence of 3-position switches. Is it possible to add the function for 3-position switches?